From ea5ecd6946a01c53f098e23b87833981abc13a37 Mon Sep 17 00:00:00 2001 From: Jeremy Diamond Date: Fri, 8 Aug 2014 21:54:43 -0700 Subject: [PATCH] API! :D --- .gitignore | 2 +- .../AlchemicalPotionCreationHandler.java | 79 +++++ .../AlchemyPotionHandlerComponent.java | 52 +++ .../api/alchemy/AlchemyPotionHelper.java | 76 ++++ .../api/alchemy/AlchemyRecipe.java | 143 ++++++++ .../api/alchemy/AlchemyRecipeRegistry.java | 85 +++++ .../api/altarRecipeRegistry/AltarRecipe.java | 70 ++++ .../AltarRecipeRegistry.java | 60 ++++ .../api/bindingRegistry/BindingRecipe.java | 30 ++ .../api/bindingRegistry/BindingRegistry.java | 67 ++++ .../api/harvest/HarvestRegistry.java | 34 ++ .../api/harvest/IHarvestHandler.java | 21 ++ .../api/items/ShapedBloodOrbRecipe.java | 227 ++++++++++++ .../api/items/ShapelessBloodOrbRecipe.java | 140 ++++++++ .../api/items/interfaces/ArmourUpgrade.java | 15 + .../api/items/interfaces/IBindable.java | 5 + .../api/items/interfaces/IBloodOrb.java | 8 + .../api/items/interfaces/IHolding.java | 6 + .../api/rituals/IMasterRitualStone.java | 30 ++ .../api/rituals/IRitualStone.java | 6 + .../api/rituals/RitualComponent.java | 43 +++ .../api/rituals/RitualEffect.java | 17 + .../api/rituals/Rituals.java | 333 ++++++++++++++++++ .../api/soulNetwork/LifeEssenceNetwork.java | 26 ++ .../api/soulNetwork/SoulNetworkHandler.java | 228 ++++++++++++ .../summoningRegistry/SummoningHelper.java | 21 ++ .../summoningRegistry/SummoningRegistry.java | 70 ++++ .../SummoningRegistryComponent.java | 231 ++++++++++++ .../api/tile/IBloodAltar.java | 26 ++ src/api/java/baubles/api/BaubleType.java | 7 + src/api/java/baubles/api/BaublesApi.java | 34 ++ src/api/java/baubles/api/IBauble.java | 46 +++ src/api/java/baubles/api/package-info.java | 5 + .../java/vazkii/botania/api/BotaniaAPI.java | 324 +++++++++++++++++ .../api/internal/DummyManaNetwork.java | 51 +++ .../api/internal/DummyMethodHandler.java | 130 +++++++ .../botania/api/internal/DummyPage.java | 35 ++ .../botania/api/internal/DummySubTile.java | 18 + .../api/internal/IGuiLexiconEntry.java | 57 +++ .../api/internal/IInternalMethodHandler.java | 79 +++++ .../botania/api/internal/IManaBurst.java | 62 ++++ .../botania/api/internal/IManaNetwork.java | 68 ++++ .../api/item/IExtendedPlayerController.java | 29 ++ .../botania/api/item/IPixieSpawner.java | 30 ++ .../botania/api/lexicon/IAddonEntry.java | 29 ++ .../vazkii/botania/api/lexicon/ILexicon.java | 21 ++ .../botania/api/lexicon/ILexiconable.java | 29 ++ .../api/lexicon/IRecipeKeyProvider.java | 24 ++ .../botania/api/lexicon/KnowledgeType.java | 20 ++ .../botania/api/lexicon/LexiconCategory.java | 32 ++ .../botania/api/lexicon/LexiconEntry.java | 94 +++++ .../botania/api/lexicon/LexiconPage.java | 53 +++ .../api/lexicon/LexiconRecipeMappings.java | 66 ++++ .../botania/api/mana/BurstProperties.java | 37 ++ .../botania/api/mana/IClientManaHandler.java | 21 ++ .../api/mana/ICreativeManaProvider.java | 26 ++ .../vazkii/botania/api/mana/IKeyLocked.java | 30 ++ .../botania/api/mana/ILaputaImmobile.java | 23 ++ .../java/vazkii/botania/api/mana/ILens.java | 43 +++ .../vazkii/botania/api/mana/ILensEffect.java | 49 +++ .../vazkii/botania/api/mana/IManaBlock.java | 26 ++ .../botania/api/mana/IManaCollector.java | 43 +++ .../botania/api/mana/IManaCollisionGhost.java | 22 ++ .../vazkii/botania/api/mana/IManaItem.java | 67 ++++ .../vazkii/botania/api/mana/IManaPool.java | 31 ++ .../botania/api/mana/IManaReceiver.java | 35 ++ .../vazkii/botania/api/mana/IManaTrigger.java | 24 ++ .../botania/api/mana/IManaUsingItem.java | 26 ++ .../api/mana/IPoolOverlayProvider.java | 26 ++ .../botania/api/mana/ITinyPlanetExcempt.java | 24 ++ .../botania/api/mana/ManaItemHandler.java | 201 +++++++++++ .../botania/api/mana/ManaNetworkEvent.java | 57 +++ .../botania/api/mana/TileSignature.java | 15 + .../java/vazkii/botania/api/package-info.java | 4 + .../vazkii/botania/api/recipe/IElvenItem.java | 14 + .../botania/api/recipe/IFlowerComponent.java | 26 ++ .../botania/api/recipe/RecipeElvenTrade.java | 94 +++++ .../api/recipe/RecipeManaInfusion.java | 81 +++++ .../botania/api/recipe/RecipePetals.java | 97 +++++ .../botania/api/recipe/RecipeRuneAltar.java | 31 ++ .../botania/api/subtile/ISpecialFlower.java | 21 ++ .../botania/api/subtile/SubTileEntity.java | 111 ++++++ .../api/subtile/SubTileFunctional.java | 190 ++++++++++ .../api/subtile/SubTileGenerating.java | 204 +++++++++++ .../botania/api/wand/ICoordBoundItem.java | 18 + .../vazkii/botania/api/wand/ITileBound.java | 31 ++ .../vazkii/botania/api/wand/IWandHUD.java | 26 ++ .../vazkii/botania/api/wand/IWandable.java | 29 ++ .../api/wand/IWireframeAABBProvider.java | 25 ++ 89 files changed, 5321 insertions(+), 1 deletion(-) create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipeRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRecipe.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/harvest/IHarvestHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/ArmourUpgrade.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBloodOrb.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IHolding.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/IMasterRitualStone.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/IRitualStone.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/LifeEssenceNetwork.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningHelper.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/tile/IBloodAltar.java create mode 100644 src/api/java/baubles/api/BaubleType.java create mode 100644 src/api/java/baubles/api/BaublesApi.java create mode 100644 src/api/java/baubles/api/IBauble.java create mode 100644 src/api/java/baubles/api/package-info.java create mode 100644 src/api/java/vazkii/botania/api/BotaniaAPI.java create mode 100644 src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java create mode 100644 src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java create mode 100644 src/api/java/vazkii/botania/api/internal/DummyPage.java create mode 100644 src/api/java/vazkii/botania/api/internal/DummySubTile.java create mode 100644 src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java create mode 100644 src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java create mode 100644 src/api/java/vazkii/botania/api/internal/IManaBurst.java create mode 100644 src/api/java/vazkii/botania/api/internal/IManaNetwork.java create mode 100644 src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java create mode 100644 src/api/java/vazkii/botania/api/item/IPixieSpawner.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/ILexicon.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/ILexiconable.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/KnowledgeType.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/LexiconPage.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java create mode 100644 src/api/java/vazkii/botania/api/mana/BurstProperties.java create mode 100644 src/api/java/vazkii/botania/api/mana/IClientManaHandler.java create mode 100644 src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java create mode 100644 src/api/java/vazkii/botania/api/mana/IKeyLocked.java create mode 100644 src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java create mode 100644 src/api/java/vazkii/botania/api/mana/ILens.java create mode 100644 src/api/java/vazkii/botania/api/mana/ILensEffect.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaBlock.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaCollector.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaItem.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaPool.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaReceiver.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaTrigger.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaUsingItem.java create mode 100644 src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java create mode 100644 src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java create mode 100644 src/api/java/vazkii/botania/api/mana/ManaItemHandler.java create mode 100644 src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java create mode 100644 src/api/java/vazkii/botania/api/mana/TileSignature.java create mode 100644 src/api/java/vazkii/botania/api/package-info.java create mode 100644 src/api/java/vazkii/botania/api/recipe/IElvenItem.java create mode 100644 src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java create mode 100644 src/api/java/vazkii/botania/api/recipe/RecipeElvenTrade.java create mode 100644 src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java create mode 100644 src/api/java/vazkii/botania/api/recipe/RecipePetals.java create mode 100644 src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java create mode 100644 src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java create mode 100644 src/api/java/vazkii/botania/api/subtile/SubTileEntity.java create mode 100644 src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java create mode 100644 src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java create mode 100644 src/api/java/vazkii/botania/api/wand/ICoordBoundItem.java create mode 100644 src/api/java/vazkii/botania/api/wand/ITileBound.java create mode 100644 src/api/java/vazkii/botania/api/wand/IWandHUD.java create mode 100644 src/api/java/vazkii/botania/api/wand/IWandable.java create mode 100644 src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java diff --git a/.gitignore b/.gitignore index d861202..55c1c5a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ /common /eclipse/* /lib/ -/src/api/* +#/src/api/* /bin/* .classpath diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java new file mode 100644 index 0000000..4a4b40e --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java @@ -0,0 +1,79 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +public class AlchemicalPotionCreationHandler +{ + public static ArrayList registeredPotionEffects = new ArrayList(); + + public static void addPotion(ItemStack itemStack, int potionID, int tickDuration) + { + registeredPotionEffects.add(new AlchemyPotionHandlerComponent(itemStack, potionID, tickDuration)); + } + + public static int getPotionIDForStack(ItemStack itemStack) + { + for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) + { + if (aphc.compareItemStack(itemStack)) + { + return aphc.getPotionID(); + } + } + + return -1; + } + + public static int getPotionTickDurationForStack(ItemStack itemStack) + { + { + for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) + { + if (aphc.compareItemStack(itemStack)) + { + return aphc.getTickDuration(); + } + } + + return -1; + } + } + + public static boolean containsRegisteredPotionIngredient(ItemStack[] stackList) + { + for (ItemStack is : stackList) + { + for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) + { + if (aphc.compareItemStack(is)) + { + return true; + } + } + } + + return false; + } + + public static int getRegisteredPotionIngredientPosition(ItemStack[] stackList) + { + int i = 0; + + for (ItemStack is : stackList) + { + for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) + { + if (aphc.compareItemStack(is)) + { + return i; + } + } + + i++; + } + + return -1; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java new file mode 100644 index 0000000..6f0d461 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java @@ -0,0 +1,52 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class AlchemyPotionHandlerComponent +{ + private ItemStack itemStack; + private int potionID; + private int tickDuration; + + public AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration) + { + this.itemStack = itemStack; + this.potionID = potionID; + this.tickDuration = tickDuration; + } + + public boolean compareItemStack(ItemStack comparedStack) + { + if (comparedStack != null && itemStack != null) + { + if (comparedStack.getItem() instanceof ItemBlock) + { + if (itemStack.getItem() instanceof ItemBlock) + { + return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage(); + } + } else if (!(itemStack.getItem() instanceof ItemBlock)) + { + return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage(); + } + } + + return false; + } + + public ItemStack getItemStack() + { + return itemStack; + } + + public int getPotionID() + { + return this.potionID; + } + + public int getTickDuration() + { + return this.tickDuration; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java new file mode 100644 index 0000000..d346255 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java @@ -0,0 +1,76 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; + +public class AlchemyPotionHelper +{ + private int potionID; + private int tickDuration; + private int concentration; + private int durationFactor; + + public AlchemyPotionHelper(int potionID, int tickDuration, int concentration, int durationFactor) + { + this.potionID = potionID; + this.tickDuration = tickDuration; + this.concentration = concentration; + this.durationFactor = durationFactor; + } + + public void setConcentration(int concentration) + { + this.concentration = concentration; + } + + public void setDurationFactor(int durationFactor) + { + this.durationFactor = durationFactor; + } + + public int getPotionID() + { + return this.potionID; + } + + public int getTickDuration() + { + return this.tickDuration; + } + + public int getConcentration() + { + return this.concentration; + } + + public int getdurationFactor() + { + return this.durationFactor; + } + + public PotionEffect getPotionEffect() + { + if (potionID == Potion.heal.id || potionID == Potion.harm.id) + { + return (new PotionEffect(potionID, 1, concentration)); + } + + return (new PotionEffect(potionID, (int) (tickDuration * Math.pow(0.5f, concentration) * Math.pow(8.0f / 3.0f, durationFactor)), concentration)); + } + + public static AlchemyPotionHelper readEffectFromNBT(NBTTagCompound tagCompound) + { + return new AlchemyPotionHelper(tagCompound.getInteger("potionID"), tagCompound.getInteger("tickDuration"), tagCompound.getInteger("concentration"), tagCompound.getInteger("durationFactor")); + } + + public static NBTTagCompound setEffectToNBT(AlchemyPotionHelper aph) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setInteger("potionID", aph.getPotionID()); + tagCompound.setInteger("tickDuration", aph.getTickDuration()); + tagCompound.setInteger("concentration", aph.getConcentration()); + tagCompound.setInteger("durationFactor", aph.getdurationFactor()); + return tagCompound; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java new file mode 100644 index 0000000..f773d06 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java @@ -0,0 +1,143 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class AlchemyRecipe +{ + private ItemStack output; + private ItemStack[] recipe; + private int bloodOrbLevel; + private int amountNeeded; + + public AlchemyRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel) + { + this.output = output; + this.recipe = recipe; + this.amountNeeded = amountNeeded; + this.bloodOrbLevel = bloodOrbLevel; + } + + public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel) + { + if (slottedBloodOrbLevel < bloodOrbLevel) + { + return false; + } + + ItemStack[] recipe = new ItemStack[5]; + + if (items.length < 5) + { + return false; + } + + if (this.recipe.length != 5) + { + ItemStack[] newRecipe = new ItemStack[5]; + + for (int i = 0; i < 5; i++) + { + if (i + 1 > this.recipe.length) + { + newRecipe[i] = null; + } else + { + newRecipe[i] = this.recipe[i]; + } + } + + recipe = newRecipe; + } else + { + recipe = this.recipe; + } + + boolean[] checkList = new boolean[5]; + + for (int i = 0; i < 5; i++) + { + checkList[i] = false; + } + + for (int i = 0; i < 5; i++) + { + ItemStack recipeItemStack = recipe[i]; + + if (recipeItemStack == null) + { + continue; + } + + boolean test = false; + + for (int j = 0; j < 5; j++) + { + if (checkList[j]) + { + continue; + } + + ItemStack checkedItemStack = items[j]; + + if (checkedItemStack == null) + { + continue; + } + + boolean quickTest = false; + + if (recipeItemStack.getItem() instanceof ItemBlock) + { + if (checkedItemStack.getItem() instanceof ItemBlock) + { + quickTest = true; + } + } else if (!(checkedItemStack.getItem() instanceof ItemBlock)) + { + quickTest = true; + } + + if (!quickTest) + { + continue; + } + + if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem()==recipeItemStack.getItem()) + { + test = true; + checkList[j] = true; + break; + } + } + + if (!test) + { + return false; + } + } + + return true; + } + + public ItemStack getResult() + { + return output.copy(); + } + + public int getAmountNeeded() + { + return this.amountNeeded; + } + + public ItemStack[] getRecipe() + { + return this.recipe; + } + + public int getOrbLevel() + { + return this.bloodOrbLevel; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java new file mode 100644 index 0000000..5753cff --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java @@ -0,0 +1,85 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; + +public class AlchemyRecipeRegistry +{ + public static List recipes = new ArrayList(); + + public static void registerRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel) + { + recipes.add(new AlchemyRecipe(output, amountNeeded, recipe, bloodOrbLevel)); + } + + public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb) + { + if (bloodOrb == null) + { + return null; + } + + if (!(bloodOrb.getItem() instanceof IBloodOrb)) + { + return null; + } + + int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel(); + + for (AlchemyRecipe ar : recipes) + { + if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) + { + return (ar.getResult()); + } + } + + return null; + } + + public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb) + { + if (bloodOrb == null) + { + return 0; + } + + if (!(bloodOrb.getItem() instanceof IBloodOrb)) + { + return 0; + } + + int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel(); + + for (AlchemyRecipe ar : recipes) + { + if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) + { + return (ar.getAmountNeeded()); + } + } + + return 0; + } + + public static ItemStack[] getRecipeForItemStack(ItemStack itemStack) + { + for (AlchemyRecipe ar : recipes) + { + ItemStack result = ar.getResult(); + + if (result != null) + { + if (result.isItemEqual(itemStack)) + { + return ar.getRecipe(); + } + } + } + + return null; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java new file mode 100644 index 0000000..624f219 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java @@ -0,0 +1,70 @@ +package WayofTime.alchemicalWizardry.api.altarRecipeRegistry; + +import net.minecraft.item.ItemStack; + +public class AltarRecipe +{ + public int minTier; + public int liquidRequired; + public boolean canBeFilled; //Tells the system that the item is an orb + public int consumptionRate; + public int drainRate; + public ItemStack requiredItem; + public ItemStack result; + + public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled) + { + this.result = result; + this.requiredItem = requiredItem; + this.minTier = minTier; + this.liquidRequired = liquidRequired; + this.consumptionRate = consumptionRate; + this.drainRate = drainRate; + this.canBeFilled = canBeFilled; + } + + public ItemStack getResult() + { + return this.result; + } + + public ItemStack getRequiredItem() + { + return this.requiredItem; + } + + public boolean doesRequiredItemMatch(ItemStack comparedStack, int tierCheck) + { + if(comparedStack == null || this.requiredItem == null) + { + return false; + } + + return tierCheck>=minTier && this.requiredItem.isItemEqual(comparedStack); + } + + public int getMinTier() + { + return this.minTier; + } + + public int getLiquidRequired() + { + return this.liquidRequired; + } + + public int getConsumptionRate() + { + return this.consumptionRate; + } + + public int getDrainRate() + { + return this.drainRate; + } + + public boolean getCanBeFilled() + { + return this.canBeFilled; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipeRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipeRegistry.java new file mode 100644 index 0000000..89c0be4 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipeRegistry.java @@ -0,0 +1,60 @@ +package WayofTime.alchemicalWizardry.api.altarRecipeRegistry; + +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class AltarRecipeRegistry +{ + public static List altarRecipes = new LinkedList(); + + public static void registerAltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled) + { + altarRecipes.add(new AltarRecipe(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled)); + } + + public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate) + { + registerAltarRecipe(null, orbStack, minTier, 0, consumptionRate, 0, true); + } + + public static boolean isRequiredItemValid(ItemStack testItem, int currentTierAltar) + { + for(AltarRecipe recipe : altarRecipes) + { + if(recipe.doesRequiredItemMatch(testItem, currentTierAltar)) + { + return true; + } + } + + return false; + } + + public static ItemStack getItemForItemAndTier(ItemStack testItem, int currentTierAltar) + { + for(AltarRecipe recipe : altarRecipes) + { + if(recipe.doesRequiredItemMatch(testItem, currentTierAltar)) + { + return ItemStack.copyItemStack(recipe.getResult()); + } + } + + return null; + } + + public static AltarRecipe getAltarRecipeForItemAndTier(ItemStack testItem, int currentTierAltar) + { + for(AltarRecipe recipe : altarRecipes) + { + if(recipe.doesRequiredItemMatch(testItem, currentTierAltar)) + { + return recipe; + } + } + + return null; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRecipe.java b/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRecipe.java new file mode 100644 index 0000000..f8d6385 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRecipe.java @@ -0,0 +1,30 @@ +package WayofTime.alchemicalWizardry.api.bindingRegistry; + +import net.minecraft.item.ItemStack; + +public class BindingRecipe +{ + public ItemStack requiredItem; + public ItemStack outputItem; + + public BindingRecipe(ItemStack outputItem, ItemStack requiredItem) + { + this.requiredItem = requiredItem; + this.outputItem = outputItem; + } + + public boolean doesRequiredItemMatch(ItemStack testStack) + { + if(testStack == null || this.requiredItem == null) + { + return false; + } + + return this.requiredItem.isItemEqual(testStack); + } + + public ItemStack getResult() + { + return this.outputItem; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java new file mode 100644 index 0000000..68f34e4 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java @@ -0,0 +1,67 @@ +package WayofTime.alchemicalWizardry.api.bindingRegistry; + +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class BindingRegistry +{ + public static List bindingRecipes = new LinkedList(); + + public static void registerRecipe(ItemStack output, ItemStack input) + { + bindingRecipes.add(new BindingRecipe(output, input)); + } + + public static boolean isRequiredItemValid(ItemStack testItem) + { + for(BindingRecipe recipe : bindingRecipes) + { + if(recipe.doesRequiredItemMatch(testItem)) + { + return true; + } + } + + return false; + } + + public static ItemStack getItemForItemAndTier(ItemStack testItem) + { + for(BindingRecipe recipe : bindingRecipes) + { + if(recipe.doesRequiredItemMatch(testItem)) + { + return recipe.getResult().copy(); + } + } + + return null; + } + + public static int getIndexForItem(ItemStack testItem) + { + int i=0; + for(BindingRecipe recipe : bindingRecipes) + { + if(recipe.doesRequiredItemMatch(testItem)) + { + return i; + } + i++; + } + + return -1; + } + + public static ItemStack getOutputForIndex(int index) + { + if(bindingRecipes.size()<=index) + { + return null; + } + + return bindingRecipes.get(index).getResult(); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java new file mode 100644 index 0000000..0d91715 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java @@ -0,0 +1,34 @@ +package WayofTime.alchemicalWizardry.api.harvest; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class HarvestRegistry +{ + public static List handlerList = new ArrayList(); + + public static void registerHarvestHandler(IHarvestHandler handler) + { + System.out.println("Heeeeelllooooo"); + handlerList.add(handler); + } + + public static boolean harvestBlock(World world, int xCoord, int yCoord, int zCoord) + { + Block block = world.getBlock(xCoord, yCoord, zCoord); + int meta = world.getBlockMetadata(xCoord, yCoord, zCoord); + + for(IHarvestHandler handler : handlerList) + { + if(handler.harvestAndPlant(world, xCoord, yCoord, zCoord, block, meta)) + { + return true; + } + } + + return false; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/harvest/IHarvestHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/harvest/IHarvestHandler.java new file mode 100644 index 0000000..888dff5 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/harvest/IHarvestHandler.java @@ -0,0 +1,21 @@ +package WayofTime.alchemicalWizardry.api.harvest; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; + +public interface IHarvestHandler +{ + /** + * A handler that is used to harvest and replant the block at the specified location + * + * @param world + * @param xCoord + * @param yCoord + * @param zCoord + * @param block block at this given location + * @param meta meta at this given location + * @return true if successfully harvested, false if not + */ + public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java new file mode 100644 index 0000000..cdf82e6 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java @@ -0,0 +1,227 @@ +package WayofTime.alchemicalWizardry.api.items; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.block.Block; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; + +/** Shaped Blood Orb Recipe Handler by joshie **/ +public class ShapedBloodOrbRecipe implements IRecipe { + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; + + private ItemStack output = null; + private Object[] input = null; + public int width = 0; + public int height = 0; + private boolean mirrored = true; + + public ShapedBloodOrbRecipe(Block result, Object... recipe) { + this(new ItemStack(result), recipe); + } + + public ShapedBloodOrbRecipe(Item result, Object... recipe) { + this(new ItemStack(result), recipe); + } + + public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) { + output = result.copy(); + + String shape = ""; + int idx = 0; + + if (recipe[idx] instanceof Boolean) { + mirrored = (Boolean) recipe[idx]; + if (recipe[idx + 1] instanceof Object[]) { + recipe = (Object[]) recipe[idx + 1]; + } else { + idx = 1; + } + } + + if (recipe[idx] instanceof String[]) { + String[] parts = ((String[]) recipe[idx++]); + + for (String s : parts) { + width = s.length(); + shape += s; + } + + height = parts.length; + } else { + while (recipe[idx] instanceof String) { + String s = (String) recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } + + if (width * height != shape.length()) { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + + HashMap itemMap = new HashMap(); + + for (; idx < recipe.length; idx += 2) { + Character chr = (Character) recipe[idx]; + Object in = recipe[idx + 1]; + + if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack)in).getItem() instanceof IBloodOrb)) { //If the item is an instanceof IBloodOrb then save the level of the orb + if(in instanceof ItemStack) itemMap.put(chr, (Integer)(((IBloodOrb)((ItemStack)in).getItem()).getOrbLevel())); + else itemMap.put(chr, (Integer)(((IBloodOrb)in).getOrbLevel())); + } else if (in instanceof ItemStack) { + itemMap.put(chr, ((ItemStack) in).copy()); + } else if (in instanceof Item) { + itemMap.put(chr, new ItemStack((Item) in)); + } else if (in instanceof Block) { + itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE)); + } else if (in instanceof String) { + itemMap.put(chr, OreDictionary.getOres((String) in)); + } else { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + + input = new Object[width * height]; + int x = 0; + for (char chr : shape.toCharArray()) { + input[x++] = itemMap.get(chr); + } + } + + ShapedBloodOrbRecipe(ShapedRecipes recipe, Map replacements) { + output = recipe.getRecipeOutput(); + width = recipe.recipeWidth; + height = recipe.recipeHeight; + + input = new Object[recipe.recipeItems.length]; + + for (int i = 0; i < input.length; i++) { + ItemStack ingred = recipe.recipeItems[i]; + + if (ingred == null) + continue; + + input[i] = recipe.recipeItems[i]; + + for (Entry replace : replacements.entrySet()) { + if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) { + input[i] = OreDictionary.getOres(replace.getValue()); + break; + } + } + } + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + return output.copy(); + } + + @Override + public int getRecipeSize() { + return input.length; + } + + @Override + public ItemStack getRecipeOutput() { + return output; + } + + @Override + public boolean matches(InventoryCrafting inv, World world) { + for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) { + for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) { + if (checkMatch(inv, x, y, false)) { + return true; + } + + if (mirrored && checkMatch(inv, x, y, true)) { + return true; + } + } + } + + return false; + } + + @SuppressWarnings("unchecked") + private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { + for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) { + for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) { + int subX = x - startX; + int subY = y - startY; + Object target = null; + + if (subX >= 0 && subY >= 0 && subX < width && subY < height) { + if (mirror) { + target = input[width - subX - 1 + subY * width]; + } else { + target = input[subX + subY * width]; + } + } + + ItemStack slot = inv.getStackInRowAndColumn(x, y); + //If target is integer, then we should be check the blood orb value of the item instead + if(target instanceof Integer) { + if(slot != null && slot.getItem() instanceof IBloodOrb) { + IBloodOrb orb = (IBloodOrb) slot.getItem(); + if(orb.getOrbLevel() < (Integer)target) { + return false; + } + } else return false; + } else if (target instanceof ItemStack) { + if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) { + return false; + } + } else if (target instanceof ArrayList) { + boolean matched = false; + + Iterator itr = ((ArrayList) target).iterator(); + while (itr.hasNext() && !matched) { + matched = OreDictionary.itemMatches(itr.next(), slot, false); + } + + if (!matched) { + return false; + } + } else if (target == null && slot != null) { + return false; + } + } + } + + return true; + } + + public ShapedBloodOrbRecipe setMirrored(boolean mirror) { + mirrored = mirror; + return this; + } + + public Object[] getInput() { + return this.input; + } +} \ No newline at end of file diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java new file mode 100644 index 0000000..fbf28a4 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java @@ -0,0 +1,140 @@ +package WayofTime.alchemicalWizardry.api.items; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.block.Block; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; + +/** Shapeless Blood Orb Recipe Handler by joshie **/ +public class ShapelessBloodOrbRecipe implements IRecipe { + private ItemStack output = null; + private ArrayList input = new ArrayList(); + + public ShapelessBloodOrbRecipe(Block result, Object... recipe) { + this(new ItemStack(result), recipe); + } + + public ShapelessBloodOrbRecipe(Item result, Object... recipe) { + this(new ItemStack(result), recipe); + } + + public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) { + output = result.copy(); + for (Object in : recipe) { + if (in instanceof ItemStack) { + input.add(((ItemStack) in).copy()); + } else if (in instanceof IBloodOrb) { //If the item is an instanceof IBloodOrb then save the level of the orb + input.add((Integer)(((IBloodOrb)in).getOrbLevel())); + } else if (in instanceof Item) { + input.add(new ItemStack((Item) in)); + } else if (in instanceof Block) { + input.add(new ItemStack((Block) in)); + } else if (in instanceof String) { + input.add(OreDictionary.getOres((String) in)); + } else { + String ret = "Invalid shapeless ore recipe: "; + for (Object tmp : recipe) { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + } + + @SuppressWarnings("unchecked") + ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map replacements) { + output = recipe.getRecipeOutput(); + + for (ItemStack ingred : ((List) recipe.recipeItems)) { + Object finalObj = ingred; + for (Entry replace : replacements.entrySet()) { + if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) { + finalObj = OreDictionary.getOres(replace.getValue()); + break; + } + } + input.add(finalObj); + } + } + + @Override + public int getRecipeSize() { + return input.size(); + } + + @Override + public ItemStack getRecipeOutput() { + return output; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + return output.copy(); + } + + @SuppressWarnings("unchecked") + @Override + public boolean matches(InventoryCrafting var1, World world) { + ArrayList required = new ArrayList(input); + + for (int x = 0; x < var1.getSizeInventory(); x++) { + ItemStack slot = var1.getStackInSlot(x); + + if (slot != null) { + boolean inRecipe = false; + Iterator req = required.iterator(); + + while (req.hasNext()) { + boolean match = false; + + Object next = req.next(); + + //If target is integer, then we should be check the blood orb value of the item instead + if(next instanceof Integer) { + if(slot != null && slot.getItem() instanceof IBloodOrb) { + IBloodOrb orb = (IBloodOrb) slot.getItem(); + if(orb.getOrbLevel() < (Integer)next) { + return false; + } + } else return false; + } else if (next instanceof ItemStack) { + match = OreDictionary.itemMatches((ItemStack) next, slot, false); + } else if (next instanceof ArrayList) { + Iterator itr = ((ArrayList) next).iterator(); + while (itr.hasNext() && !match) { + match = OreDictionary.itemMatches(itr.next(), slot, false); + } + } + + if (match) { + inRecipe = true; + required.remove(next); + break; + } + } + + if (!inRecipe) { + return false; + } + } + } + + return required.isEmpty(); + } + + public ArrayList getInput() { + return this.input; + } +} \ No newline at end of file diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/ArmourUpgrade.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/ArmourUpgrade.java new file mode 100644 index 0000000..7fce7cd --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/ArmourUpgrade.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface ArmourUpgrade +{ + //Called when the armour ticks + public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack); + + public boolean isUpgrade(); + + public int getEnergyForTenSeconds(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java new file mode 100644 index 0000000..46a7993 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java @@ -0,0 +1,5 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +public interface IBindable +{ +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBloodOrb.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBloodOrb.java new file mode 100644 index 0000000..794172c --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBloodOrb.java @@ -0,0 +1,8 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +public interface IBloodOrb +{ + public int getMaxEssence(); + + public int getOrbLevel(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IHolding.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IHolding.java new file mode 100644 index 0000000..cb07b99 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IHolding.java @@ -0,0 +1,6 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +public interface IHolding +{ + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IMasterRitualStone.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IMasterRitualStone.java new file mode 100644 index 0000000..9777093 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IMasterRitualStone.java @@ -0,0 +1,30 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import net.minecraft.world.World; + +public interface IMasterRitualStone +{ + public void performRitual(World world, int x, int y, int z, String ritualID); + + public String getOwner(); + + public void setCooldown(int newCooldown); + + public int getCooldown(); + + public void setVar1(int newVar1); + + public int getVar1(); + + public void setActive(boolean active); + + public int getDirection(); + + public World getWorld(); + + public int getXCoord(); + + public int getYCoord(); + + public int getZCoord(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IRitualStone.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IRitualStone.java new file mode 100644 index 0000000..078cfd4 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IRitualStone.java @@ -0,0 +1,6 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +public interface IRitualStone +{ + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java new file mode 100644 index 0000000..b714985 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java @@ -0,0 +1,43 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +public class RitualComponent +{ + private int x; + private int y; + private int z; + private int stoneType; + public static final int BLANK = 0; + public static final int WATER = 1; + public static final int FIRE = 2; + public static final int EARTH = 3; + public static final int AIR = 4; + public static final int DUSK = 5; + + public RitualComponent(int x, int y, int z, int stoneType) + { + this.x = x; + this.y = y; + this.z = z; + this.stoneType = stoneType; + } + + public int getX() + { + return this.x; + } + + public int getY() + { + return this.y; + } + + public int getZ() + { + return this.z; + } + + public int getStoneType() + { + return this.stoneType; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualEffect.java new file mode 100644 index 0000000..70f89f5 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualEffect.java @@ -0,0 +1,17 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import java.util.List; + +public abstract class RitualEffect +{ + public abstract void performEffect(IMasterRitualStone ritualStone); + + public abstract int getCostPerRefresh(); + + public int getInitialCooldown() + { + return 0; + } + + public abstract List getRitualComponentList(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java new file mode 100644 index 0000000..7eca627 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java @@ -0,0 +1,333 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import scala.reflect.internal.Trees.This; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class Rituals +{ + private int crystalLevel; + private int actCost; + private RitualEffect effect; + private String name; + + public static Map ritualMap = new HashMap(); + @Deprecated + public static List ritualList = new LinkedList(); + public static List keyList = new LinkedList(); + + public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name) + { + this.crystalLevel = crystalLevel; //For a test commit + this.actCost = actCost; + this.effect = effect; + this.name = name; + keyList.add(name); + ritualMap.put(name, this); + } + + /** + * Static method to register a ritual to the Ritual Registry + * @param key Unique identification key - must be different from all others to properly register + * @param crystalLevel Crystal level required to activate + * @param actCost LP amount required to activate + * @param effect The effect that will be ticked + * @param name The name of the ritual + * @return Returns true if properly registered, or false if the key is already used + */ + public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name) + { + if(ritualMap.containsKey(key)) + { + return false; + } + else + { + Rituals ritual = new Rituals(crystalLevel, actCost, effect, name); + ritual.removeRitualFromList(); + ritualMap.put(key, ritual); + keyList.add(key); + return true; + } + } + + public void removeRitualFromList() + { + if(ritualMap.containsValue(this)) + { + ritualMap.remove(ritualMap.remove(this.name)); + } + if(keyList.contains(this.name)) + { + keyList.remove(this.name); + } + } + + public static String checkValidRitual(World world, int x, int y, int z) + { + for(String key : ritualMap.keySet()) + { + if(checkRitualIsValid(world,x,y,z,key)) + { + return key; + } + } + + return ""; + } + + public static boolean canCrystalActivate(String ritualID, int crystalLevel) + { + if(ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if(ritual != null) + { + return ritual.getCrystalLevel() <= crystalLevel; + } + } + + return false; + } + + public static boolean checkRitualIsValid(World world, int x, int y, int z, String ritualID) + { + int direction = Rituals.getDirectionOfRitual(world, x, y, z, ritualID); + + if (direction != -1) + { + return true; + } + + return false; + } + + /** + * 1 - NORTH + * 2 - EAST + * 3 - SOUTH + * 4 - WEST + */ + public static boolean checkDirectionOfRitualValid(World world, int x, int y, int z, String ritualID, int direction) + { + List ritual = Rituals.getRitualList(ritualID); + + if (ritual == null) + { + return false; + } + + Block test = null; + + switch (direction) + { + case 1: + for (RitualComponent rc : ritual) + { + test = world.getBlock(x + rc.getX(), y + rc.getY(), z + rc.getZ()); + + if (!(test instanceof IRitualStone)) + { + return false; + } + + if (world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ()) != rc.getStoneType()) + { + return false; + } + } + + return true; + + case 2: + for (RitualComponent rc : ritual) + { + test = world.getBlock(x - rc.getZ(), y + rc.getY(), z + rc.getX()); + + if (!(test instanceof IRitualStone)) + { + return false; + } + + if (world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX()) != rc.getStoneType()) + { + return false; + } + } + + return true; + + case 3: + for (RitualComponent rc : ritual) + { + test = world.getBlock(x - rc.getX(), y + rc.getY(), z - rc.getZ()); + + if (!(test instanceof IRitualStone)) + { + return false; + } + + if (world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ()) != rc.getStoneType()) + { + return false; + } + } + + return true; + + case 4: + for (RitualComponent rc : ritual) + { + test = world.getBlock(x + rc.getZ(), y + rc.getY(), z - rc.getX()); + + if (!(test instanceof IRitualStone)) + { + return false; + } + + if (world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX()) != rc.getStoneType()) + { + return false; + } + } + + return true; + } + + return false; + } + + public static int getDirectionOfRitual(World world, int x, int y, int z, String ritualID) + { + for (int i = 1; i <= 4; i++) + { + if (Rituals.checkDirectionOfRitualValid(world, x, y, z, ritualID, i)) + { + return i; + } + } + + return -1; + } + + public static int getCostForActivation(String ritualID) + { + if(ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if(ritual != null) + { + return ritual.actCost; + } + } + + return 0; + } + + public static int getInitialCooldown(String ritualID) + { + if(ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if(ritual != null && ritual.effect != null) + { + return ritual.effect.getInitialCooldown(); + } + } + + return 0; + } + + public static List getRitualList(String ritualID) + { + if(ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if(ritual != null) + { + return ritual.obtainComponents(); + }else + { + return null; + } + }else + { + return null; + } + } + + private List obtainComponents() + { + return this.effect.getRitualComponentList(); + } + + private int getCrystalLevel() + { + return this.crystalLevel; + } + + public static void performEffect(IMasterRitualStone ritualStone, String ritualID) + { + if(ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if(ritual != null && ritual.effect != null) + { + ritual.effect.performEffect(ritualStone); + } + } + } + + public static int getNumberOfRituals() + { + return ritualMap.size(); + } + + public String getRitualName() + { + return this.name; + } + + public static String getNameOfRitual(String id) + { + if(ritualMap.containsKey(id)) + { + Rituals ritual = ritualMap.get(id); + if(ritual != null) + { + return ritual.getRitualName(); + } + } + + return ""; + } + + public static String getNextRitualKey(String key) + { + boolean hasSpotted = false; + String firstKey = ""; + + for(String str : keyList) + { + if(firstKey.equals("")) + { + firstKey = str; + } + if(hasSpotted) + { + return str; + } + if(str.equals(key)) + { + hasSpotted = true; + } + } + + return firstKey; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/LifeEssenceNetwork.java b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/LifeEssenceNetwork.java new file mode 100644 index 0000000..61d24ee --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/LifeEssenceNetwork.java @@ -0,0 +1,26 @@ +package WayofTime.alchemicalWizardry.api.soulNetwork; + +import net.minecraft.nbt.NBTTagCompound; + +public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData +{ + public int currentEssence; + + public LifeEssenceNetwork(String par1Str) + { + super(par1Str); + currentEssence = 0; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + currentEssence = nbttagcompound.getInteger("currentEssence"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + nbttagcompound.setInteger("currentEssence", currentEssence); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java new file mode 100644 index 0000000..a4d6858 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java @@ -0,0 +1,228 @@ +package WayofTime.alchemicalWizardry.api.soulNetwork; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public class SoulNetworkHandler +{ + public static int syphonFromNetwork(ItemStack ist, int damageToBeDone) + { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) + { + String ownerName = ist.getTagCompound().getString("ownerName"); + + if (MinecraftServer.getServer() == null) + { + return 0; + } + + World world = MinecraftServer.getServer().worldServers[0]; + LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); + + if (data == null) + { + data = new LifeEssenceNetwork(ownerName); + world.setItemData(ownerName, data); + } + + if (data.currentEssence >= damageToBeDone) + { + data.currentEssence -= damageToBeDone; + data.markDirty(); + return damageToBeDone; + } + } + return 0; + } + + /** + * Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP. + * Does not drain on the client side. + * + * @param ist Owned itemStack + * @param player Player using the item + * @param damageToBeDone + * @return True if server-sided, false if client-sided + */ + public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer player, int damageToBeDone) + { + if(player.worldObj.isRemote) + { + return false; + } + + int amount = SoulNetworkHandler.syphonFromNetwork(ist, damageToBeDone); + + hurtPlayer(player, damageToBeDone-amount); + + return true; + } + + public static boolean canSyphonFromOnlyNetwork(ItemStack ist, int damageToBeDone) + { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) + { + String ownerName = ist.getTagCompound().getString("ownerName"); + + if (MinecraftServer.getServer() == null) + { + return false; + } + + World world = MinecraftServer.getServer().worldServers[0]; + LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); + + if (data == null) + { + data = new LifeEssenceNetwork(ownerName); + world.setItemData(ownerName, data); + } + + return data.currentEssence >= damageToBeDone; + } + + return false; + } + + public static int getCurrentEssence(String ownerName) + { + if (MinecraftServer.getServer() == null) + { + return 0; + } + + World world = MinecraftServer.getServer().worldServers[0]; + LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); + + if (data == null) + { + data = new LifeEssenceNetwork(ownerName); + world.setItemData(ownerName, data); + } + + return data.currentEssence; + } + + public static void setCurrentEssence(String ownerName, int essence) + { + if (MinecraftServer.getServer() == null) + { + return; + } + + World world = MinecraftServer.getServer().worldServers[0]; + LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); + + if (data == null) + { + data = new LifeEssenceNetwork(ownerName); + world.setItemData(ownerName, data); + } + + data.currentEssence = essence; + data.markDirty(); + } + + /** + * A method to add to an owner's network up to a maximum value. + * + * @param ownerName + * @param addedEssence + * @param maximum + * @return amount added to the network + */ + public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) + { + if (MinecraftServer.getServer() == null) + { + return 0; + } + + World world = MinecraftServer.getServer().worldServers[0]; + LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); + + if (data == null) + { + data = new LifeEssenceNetwork(ownerName); + world.setItemData(ownerName, data); + } + + int currEss = data.currentEssence; + + if(currEss>=maximum) + { + return 0; + } + + int newEss = Math.min(maximum, currEss+addedEssence); + data.currentEssence = newEss; + + return newEss-currEss; + } + + public static void hurtPlayer(EntityPlayer user, int energySyphoned) + { + if (energySyphoned < 100 && energySyphoned > 0) + { + if (!user.capabilities.isCreativeMode) + { + user.setHealth((user.getHealth() - 1)); + + if (user.getHealth() <= 0.0005f) + { + user.onDeath(DamageSource.generic); + } + } + } else if (energySyphoned >= 100) + { + if (!user.capabilities.isCreativeMode) + { + for (int i = 0; i < ((energySyphoned + 99) / 100); i++) + { + user.setHealth((user.getHealth() - 1)); + + if (user.getHealth() <= 0.0005f) + { + user.onDeath(DamageSource.generic); + break; + } + } + } + } + } + + public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player) + { + if (item.stackTagCompound == null) + { + item.setTagCompound(new NBTTagCompound()); + } + + if (item.stackTagCompound.getString("ownerName").equals("")) + { + item.stackTagCompound.setString("ownerName", SoulNetworkHandler.getUsername(player)); + } + } + + public static void checkAndSetItemOwner(ItemStack item, String ownerName) + { + if (item.stackTagCompound == null) + { + item.setTagCompound(new NBTTagCompound()); + } + + if (item.stackTagCompound.getString("ownerName").equals("")) + { + item.stackTagCompound.setString("ownerName", ownerName); + } + } + + public static String getUsername(EntityPlayer player) + { + return player.getDisplayName(); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningHelper.java b/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningHelper.java new file mode 100644 index 0000000..cccfe3f --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningHelper.java @@ -0,0 +1,21 @@ +package WayofTime.alchemicalWizardry.api.summoningRegistry; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; + +public abstract class SummoningHelper +{ + protected int id; + + public SummoningHelper(int id) + { + this.id = id; + } + + public abstract EntityLivingBase getEntity(World worldObj); + + public int getSummoningHelperID() + { + return id; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java new file mode 100644 index 0000000..9fda582 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java @@ -0,0 +1,70 @@ +package WayofTime.alchemicalWizardry.api.summoningRegistry; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; + +public class SummoningRegistry +{ + public static List summoningList = new ArrayList(); + + public static void registerSummon(SummoningHelper s, ItemStack[] ring1, ItemStack[] ring2, ItemStack[] ring3, int amountUsed, int bloodOrbLevel) + { + summoningList.add(new SummoningRegistryComponent(s, ring1, ring2, ring3, amountUsed, bloodOrbLevel)); + } + + public static boolean isRecipeValid(int bloodOrbLevel, ItemStack[] test1, ItemStack[] test2, ItemStack[] test3) + { + for (SummoningRegistryComponent src : summoningList) + { + if (src.getBloodOrbLevel() <= bloodOrbLevel && src.compareRing(1, test1) && src.compareRing(2, test2) && src.compareRing(3, test3)) + { + return true; + } + } + + return false; + } + + public static SummoningRegistryComponent getRegistryComponent(int bloodOrbLevel, ItemStack[] test1, ItemStack[] test2, ItemStack[] test3) + { + for (SummoningRegistryComponent src : summoningList) + { + if (src.getBloodOrbLevel() <= bloodOrbLevel && src.compareRing(1, test1) && src.compareRing(2, test2) && src.compareRing(3, test3)) + { + return src; + } + } + + return null; + } + + public static EntityLivingBase getEntity(World worldObj, int bloodOrbLevel, ItemStack[] test1, ItemStack[] test2, ItemStack[] test3) + { + for (SummoningRegistryComponent src : summoningList) + { + if (src.getBloodOrbLevel() <= bloodOrbLevel && src.compareRing(1, test1) && src.compareRing(2, test2) && src.compareRing(3, test3)) + { + return src.getEntity(worldObj); + } + } + + return null; + } + + public static EntityLivingBase getEntityWithID(World worldObj, int id) + { + for (SummoningRegistryComponent src : summoningList) + { + if (src.getSummoningHelperID() == id) + { + return src.getEntity(worldObj); + } + } + + return null; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java b/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java new file mode 100644 index 0000000..8496b0f --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java @@ -0,0 +1,231 @@ +package WayofTime.alchemicalWizardry.api.summoningRegistry; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + +public class SummoningRegistryComponent +{ + public ItemStack[] ring1 = new ItemStack[6]; + public ItemStack[] ring2 = new ItemStack[6]; + public ItemStack[] ring3 = new ItemStack[6]; + public SummoningHelper summoningHelper; + public int summoningCost; + public int bloodOrbLevel; + + public SummoningRegistryComponent(SummoningHelper s, ItemStack[] newRing1, ItemStack[] newRing2, ItemStack[] newRing3, int amount, int bloodOrbLevel) + { + this.summoningHelper = s; + this.ring1 = newRing1; + this.ring2 = newRing2; + this.ring3 = newRing3; + this.summoningCost = amount; + this.bloodOrbLevel = bloodOrbLevel; + + if (this.ring1.length != 6) + { + ItemStack[] newRecipe = new ItemStack[6]; + + for (int i = 0; i < 6; i++) + { + if (i + 1 > this.ring1.length) + { + newRecipe[i] = null; + } else + { + newRecipe[i] = this.ring1[i]; + } + } + + this.ring1 = newRecipe; + } + + if (this.ring2.length != 6) + { + ItemStack[] newRecipe = new ItemStack[6]; + + for (int i = 0; i < 6; i++) + { + if (i + 1 > this.ring2.length) + { + newRecipe[i] = null; + } else + { + newRecipe[i] = this.ring2[i]; + } + } + + this.ring2 = newRecipe; + } + + if (this.ring3.length != 6) + { + ItemStack[] newRecipe = new ItemStack[6]; + + for (int i = 0; i < 6; i++) + { + if (i + 1 > this.ring3.length) + { + newRecipe[i] = null; + } else + { + newRecipe[i] = this.ring3[i]; + } + } + + this.ring3 = newRecipe; + } + } + + public boolean compareRing(int ring, ItemStack[] checkedRingRecipe) + { + ItemStack[] recipe; + + if (checkedRingRecipe.length < 6) + { + return false; + } + + switch (ring) + { + case 1: + recipe = ring1; + break; + + case 2: + recipe = ring2; + break; + + case 3: + recipe = ring3; + break; + + default: + recipe = ring1; + } + + if (recipe.length != 6) + { + ItemStack[] newRecipe = new ItemStack[6]; + + for (int i = 0; i < 6; i++) + { + if (i + 1 > recipe.length) + { + newRecipe[i] = null; + } else + { + newRecipe[i] = recipe[i]; + } + } + + recipe = newRecipe; + } + + boolean[] checkList = new boolean[6]; + + for (int i = 0; i < 6; i++) + { + checkList[i] = false; + } + + for (int i = 0; i < 6; i++) + { + ItemStack recipeItemStack = recipe[i]; + + if (recipeItemStack == null) + { + continue; + } + + boolean test = false; + + for (int j = 0; j < 6; j++) + { + if (checkList[j]) + { + continue; + } + + ItemStack checkedItemStack = checkedRingRecipe[j]; + + if (checkedItemStack == null) + { + continue; + } + + boolean quickTest = false; + + if (recipeItemStack.getItem() instanceof ItemBlock) + { + if (checkedItemStack.getItem() instanceof ItemBlock) + { + quickTest = true; + } + } else if (!(checkedItemStack.getItem() instanceof ItemBlock)) + { + quickTest = true; + } + + if (!quickTest) + { + continue; + } + + if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem()) + { + test = true; + checkList[j] = true; + break; + } + } + + if (!test) + { + return false; + } + } + + return true; + } + + public int getSummoningCost() + { + return summoningCost; + } + + public EntityLivingBase getEntity(World world) + { + return this.summoningHelper.getEntity(world); + } + + public int getBloodOrbLevel() + { + return this.bloodOrbLevel; + } + + public ItemStack[] getRingRecipeForRing(int ring) + { + switch (ring) + { + case 1: + return ring1; + + case 2: + return ring2; + + case 3: + return ring3; + + default: + return null; + } + } + + public int getSummoningHelperID() + { + return this.summoningHelper.getSummoningHelperID(); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/tile/IBloodAltar.java b/src/api/java/WayofTime/alchemicalWizardry/api/tile/IBloodAltar.java new file mode 100644 index 0000000..c70d618 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/tile/IBloodAltar.java @@ -0,0 +1,26 @@ +package WayofTime.alchemicalWizardry.api.tile; + +/** + * Created by Pokefenn. + */ +public interface IBloodAltar +{ + + public int getCapacity(); + + public int getCurrentBlood(); + + public int getTier(); + + public int getProgress(); + + public float getSacrificeMultiplier(); + + public float getSelfSacrificeMultiplier(); + + public float getOrbMultiplier(); + + public float getDislocationMultiplier(); + + public int getBufferCapacity(); +} diff --git a/src/api/java/baubles/api/BaubleType.java b/src/api/java/baubles/api/BaubleType.java new file mode 100644 index 0000000..22349ff --- /dev/null +++ b/src/api/java/baubles/api/BaubleType.java @@ -0,0 +1,7 @@ +package baubles.api; + +public enum BaubleType { + RING, + AMULET, + BELT +} diff --git a/src/api/java/baubles/api/BaublesApi.java b/src/api/java/baubles/api/BaublesApi.java new file mode 100644 index 0000000..ca94fcd --- /dev/null +++ b/src/api/java/baubles/api/BaublesApi.java @@ -0,0 +1,34 @@ +package baubles.api; + +import java.lang.reflect.Method; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import cpw.mods.fml.common.FMLLog; + + + +/** + * @author Azanor + */ +public class BaublesApi { + + static Method getBaubles; + /** + * Retrieves the baubles inventory for the supplied player + */ + public static IInventory getBaubles(EntityPlayer player) { + IInventory ot = null; + try { + if(getBaubles == null) { + Class fake = Class.forName("baubles.common.lib.PlayerHandler"); + getBaubles = fake.getMethod("getPlayerBaubles", EntityPlayer.class); + } + ot = (IInventory) getBaubles.invoke(null, player); + } catch(Exception ex) { + FMLLog.warning("[Baubles API] Could not invoke baubles.common.lib.PlayerHandler method getPlayerBaubles"); + } + return ot; + } + +} diff --git a/src/api/java/baubles/api/IBauble.java b/src/api/java/baubles/api/IBauble.java new file mode 100644 index 0000000..de85ff1 --- /dev/null +++ b/src/api/java/baubles/api/IBauble.java @@ -0,0 +1,46 @@ +package baubles.api; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * + * @author Azanor + * + * This interface should be extended by items that can be worn in bauble slots + * + */ + +public interface IBauble { + + /** + * This method return the type of bauble this is. + * Type is used to determine the slots it can go into. + */ + public BaubleType getBaubleType(ItemStack itemstack); + + /** + * This method is called once per tick if the bauble is being worn by a player + */ + public void onWornTick(ItemStack itemstack, EntityLivingBase player); + + /** + * This method is called when the bauble is equipped by a player + */ + public void onEquipped(ItemStack itemstack, EntityLivingBase player); + + /** + * This method is called when the bauble is unequipped by a player + */ + public void onUnequipped(ItemStack itemstack, EntityLivingBase player); + + /** + * can this bauble be placed in a bauble slot + */ + public boolean canEquip(ItemStack itemstack, EntityLivingBase player); + + /** + * Can this bauble be removed from a bauble slot + */ + public boolean canUnequip(ItemStack itemstack, EntityLivingBase player); +} diff --git a/src/api/java/baubles/api/package-info.java b/src/api/java/baubles/api/package-info.java new file mode 100644 index 0000000..15b770d --- /dev/null +++ b/src/api/java/baubles/api/package-info.java @@ -0,0 +1,5 @@ +@API(owner = "Baubles", apiVersion = baubles.common.Baubles.VERSION, provides = "Baubles|API") +package baubles.api; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/vazkii/botania/api/BotaniaAPI.java b/src/api/java/vazkii/botania/api/BotaniaAPI.java new file mode 100644 index 0000000..5a7b141 --- /dev/null +++ b/src/api/java/vazkii/botania/api/BotaniaAPI.java @@ -0,0 +1,324 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)] + */ +package vazkii.botania.api; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemArmor.ArmorMaterial; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.EnumHelper; +import vazkii.botania.api.internal.DummyMethodHandler; +import vazkii.botania.api.internal.DummySubTile; +import vazkii.botania.api.internal.IInternalMethodHandler; +import vazkii.botania.api.lexicon.KnowledgeType; +import vazkii.botania.api.lexicon.LexiconCategory; +import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.recipe.RecipeElvenTrade; +import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RecipePetals; +import vazkii.botania.api.recipe.RecipeRuneAltar; +import vazkii.botania.api.subtile.SubTileEntity; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +public final class BotaniaAPI { + + private static List categories = new ArrayList(); + private static List allEntries = new ArrayList(); + + public static Map knowledgeTypes = new HashMap(); + + public static List petalRecipes = new ArrayList(); + public static List runeAltarRecipes = new ArrayList(); + public static List manaInfusionRecipes = new ArrayList(); + public static List elvenTradeRecipes = new ArrayList(); + + private static BiMap> subTiles = HashBiMap.> create(); + public static Set subtilesForCreativeMenu = new LinkedHashSet(); + + public static Map oreWeights = new HashMap(); + + public static Map seeds = new HashMap(); + + public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] { 2, 6, 5, 2 }, 18); + public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); + + public static ArmorMaterial elementiumArmorMaterial = EnumHelper.addArmorMaterial("B_ELEMENTIUM", 18, new int[] { 2, 6, 5, 2 }, 18); + public static ToolMaterial elementiumToolMaterial = EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20); + + public static ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26); + public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 3, 2300, 9F, 3F, 26); + + public static KnowledgeType basicKnowledge, elvenKnowledge; + + static { + registerSubTile("", DummySubTile.class); + + basicKnowledge = registerKnowledgeType("minecraft", EnumChatFormatting.RESET, true); + elvenKnowledge = registerKnowledgeType("alfheim", EnumChatFormatting.DARK_GREEN, false); + + addOreWeight("oreAluminum", 3940); // Tinkers' Construct + addOreWeight("oreAmber", 2075); // Thaumcraft + addOreWeight("oreApatite", 1595); // Forestry + addOreWeight("oreBlueTopaz", 3195); // Ars Magica + addOreWeight("oreCassiterite", 1634); // GregTech + addOreWeight("oreCertusQuartz", 3975); // Applied Energistics + addOreWeight("oreChimerite", 3970); // Ars Magica + addOreWeight("oreCinnabar", 2585); // Thaumcraft + addOreWeight("oreCoal", 46525); // Vanilla + addOreWeight("oreCooperite", 5); // GregTech + addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc. + addOreWeight("oreDarkIron", 1700); // Factorization + addOreWeight("oreDiamond", 1265); // Vanilla + addOreWeight("oreEmerald", 780); // Vanilla + addOreWeight("oreEmery", 415); // GregTech + addOreWeight("oreGalena", 1000); // Factorization + addOreWeight("oreGold", 2970); // Vanilla + addOreWeight("oreInfusedAir", 925); // Thaumcraft + addOreWeight("oreInfusedEarth", 925); // Thaumcraft + addOreWeight("oreInfusedEntropy", 925); // Thaumcraft + addOreWeight("oreInfusedFire", 925); // Thaumcraft + addOreWeight("oreInfusedOrder", 925); // Thaumcraft + addOreWeight("oreInfusedWater", 925); // Thaumcraft + addOreWeight("oreIridium", 30); // GregTech + addOreWeight("oreIron", 20665); // Vanilla + addOreWeight("oreLapis", 1285); // Vanilla + addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc. + addOreWeight("oreMCropsEssence", 3085); // Magical Crops + addOreWeight("oreNickel", 2275); // Thermal Expansion + addOreWeight("oreOlivine", 1100); // Project RED + addOreWeight("oreRedstone", 6885); // Vanilla + addOreWeight("oreRuby", 1100); // Project RED + addOreWeight("oreSapphire", 1100); // Project RED + addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc. + addOreWeight("oreSphalerite", 25); // GregTech + addOreWeight("oreSulfur", 1105); // Railcraft + addOreWeight("oreTetrahedrite", 4040); // GregTech + addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc. + addOreWeight("oreTungstate", 20); // GregTech + addOreWeight("oreUranium", 1337); // IC2 + addOreWeight("oreVinteum", 5925); // Ars Magica + addOreWeight("oreYellorite", 3520); // Big Reactors + addOreWeight("oreZinc", 6485); // Flaxbeard's Steam Power + + addSeed(Items.wheat_seeds, Blocks.wheat); + addSeed(Items.potato, Blocks.potatoes); + addSeed(Items.carrot, Blocks.carrots); + addSeed(Items.nether_wart, Blocks.nether_wart); + addSeed(Items.pumpkin_seeds, Blocks.pumpkin_stem); + addSeed(Items.melon_seeds, Blocks.melon_stem); + } + + /** + * The internal method handler in use. Do not overwrite. + * @see IInternalMethodHandler + */ + public static IInternalMethodHandler internalHandler = new DummyMethodHandler(); + + + /** + * Registers a new Knowledge Type. + * @param id The ID for this knowledge type. + * @param color The color to display this knowledge type as. + */ + public static KnowledgeType registerKnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { + KnowledgeType type = new KnowledgeType(id, color, autoUnlock); + knowledgeTypes.put(id, type); + return type; + } + + /** + * Registers a Petal Recipe. + * @param output The ItemStack to craft. + * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper + * or String (case for Ore Dictionary). The array can't be larger than 16. + * @return The recipe created. + */ + public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) { + RecipePetals recipe = new RecipePetals(output, inputs); + petalRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Rune Altar + * @param output The ItemStack to craft. + * @param mana The amount of mana required. Don't go over 100000! + * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper + * or String (case for Ore Dictionary). The array can't be larger than 16. + * @return The recipe created. + */ + public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) { + RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); + runeAltarRecipes.add(recipe); + return recipe; + } + + /** + * Registers a Mana Infusion Recipe (throw an item in a mana pool) + * @param output The ItemStack to craft + * @param input The input item, be it an ItemStack or an ore dictionary entry String. + * @param mana The amount of mana required. Don't go over 100000! + * @return The recipe created. + */ + public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); + manaInfusionRecipes.add(recipe); + return recipe; + } + + /** + * Register a Mana Infusion Recipe and flags it as an Alchemy recipe (requires an + * Alchemy Catalyst below the pool). + * @see BotaniaAPI#registerManaInfusionRecipe + */ + public static RecipeManaInfusion registerManaAlchemyRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = registerManaInfusionRecipe(output, input, mana); + recipe.setAlchemy(true); + return recipe; + } + + /** + * Register a Mana Infusion Recipe and flags it as an Conjuration recipe (requires a + * Conjuration Catalyst below the pool). + * @see BotaniaAPI#registerManaInfusionRecipe + */ + public static RecipeManaInfusion registerManaConjurationRecipe(ItemStack output, Object input, int mana) { + RecipeManaInfusion recipe = registerManaInfusionRecipe(output, input, mana); + recipe.setConjuration(true); + return recipe; + } + + /** + * Registers a Elven Trade recipe (throw an item in an Alfheim Portal). + * @param output The ItemStack to return. + * @param inputs The items required, can be ItemStack or ore dictionary entry string. + * @return The recipe created. + */ + public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) { + RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs); + elvenTradeRecipes.add(recipe); + return recipe; + } + + /** + * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. + */ + public static void registerSubTile(String key, Class subtileClass) { + subTiles.put(key, subtileClass); + } + + /** + * Adds the key for a SubTileEntity into the creative menu. This goes into the + * subtilesForCreativeMenu Set. + */ + public static void addSubTileToCreativeMenu(String key) { + subtilesForCreativeMenu.add(key); + } + + /** + * Adds a category to the list of registered categories to appear in the Lexicon. + */ + public static void addCategory(LexiconCategory category) { + categories.add(category); + } + + /** + * Gets all registered categories. + */ + public static List getAllCategories() { + return categories; + } + + /** + * Gets all registered entries. + */ + public static List getAllEntries() { + return allEntries; + } + + /** + * Registers a Lexicon Entry and adds it to the category passed in. + */ + public static void addEntry(LexiconEntry entry, LexiconCategory category) { + allEntries.add(entry); + category.entries.add(entry); + } + + /** + * Maps an ore (ore dictionary key) to it's weight on the world generation. This + * is used for the Orechid flower. Check the static block in the BotaniaAPI class + * to get the weights for the vanilla blocks.
+ * Alternatively get the values with the OreDetector mod:
+ * https://gist.github.com/Vazkii/9493322 + */ + public static void addOreWeight(String ore, int weight) { + oreWeights.put(ore, weight); + } + + public static int getOreWeight(String ore) { + return oreWeights.get(ore); + } + + /** + * Allows an item to be counted as a seed. Any item in this list can be + * dispensed by a dispenser, the block is the block to be placed. + */ + public static void addSeed(Item item, Block block) { + seeds.put(item, block); + } + + /** + * Gets the last recipe to have been added to the recipe list. + */ + public static IRecipe getLatestAddedRecipe() { + List list = CraftingManager.getInstance().getRecipeList(); + return list.get(list.size() - 1); + } + + /** + * Gets the last x recipes added to the recipe list. + */ + public static List getLatestAddedRecipes(int x) { + List list = CraftingManager.getInstance().getRecipeList(); + List newList = new ArrayList(); + for(int i = x - 1; i >= 0; i--) + newList.add(list.get(list.size() - 1 - i)); + + return newList; + } + + public static Class getSubTileMapping(String key) { + if(!subTiles.containsKey(key)) + key = ""; + + return subTiles.get(key); + } + + public static String getSubTileStringMapping(Class clazz) { + return subTiles.inverse().get(clazz); + } +} diff --git a/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java b/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java new file mode 100644 index 0000000..53a8e42 --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java @@ -0,0 +1,51 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 7, 2014, 3:47:43 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import vazkii.botania.api.mana.TileSignature; + +public class DummyManaNetwork implements IManaNetwork { + + public static final DummyManaNetwork instance = new DummyManaNetwork(); + + @Override + public void clear() { + // NO-OP + } + + @Override + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit) { + return null; + } + + @Override + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit) { + return null; + } + + @Override + public List getAllCollectorsInWorld(World world) { + return new ArrayList(); + } + + @Override + public List getAllPoolsInWorld(World world) { + return new ArrayList(); + } + +} diff --git a/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java b/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java new file mode 100644 index 0000000..29675d6 --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java @@ -0,0 +1,130 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:43:03 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import java.util.List; + +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import vazkii.botania.api.lexicon.LexiconPage; +import vazkii.botania.api.recipe.RecipeElvenTrade; +import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RecipePetals; +import vazkii.botania.api.recipe.RecipeRuneAltar; + +public class DummyMethodHandler implements IInternalMethodHandler { + + @Override + public LexiconPage textPage(String key) { + return dummyPage(key); + } + + @Override + public LexiconPage imagePage(String key, String resource) { + return dummyPage(key); + } + + @Override + public LexiconPage craftingRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage craftingRecipePage(String key, IRecipe recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage petalRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage petalRecipePage(String key, RecipePetals recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage runeRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage manaInfusionRecipesPage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) { + return dummyPage(key); + } + + @Override + public LexiconPage elvenTradePage(String key, List recipes) { + return dummyPage(key); + } + + @Override + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe) { + return dummyPage(key); + } + + private LexiconPage dummyPage(String key) { + return new DummyPage(key); + } + + @Override + public ItemStack getSubTileAsStack(String subTile) { + return new ItemStack(Blocks.stone, 0, 0); + } + + @Override + public IIcon getSubTileIconForName(String name) { + return Blocks.red_flower.getIcon(0, 0); + } + + @Override + public IManaNetwork getManaNetworkInstance() { + return DummyManaNetwork.instance; + } + + @Override + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { + // NO-OP + } + + @Override + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { + // NO-OP + } + + @Override + public IInventory getBaublesInventory(EntityPlayer player) { + return null; + } + + @Override + public boolean shouldForceCheck() { + return true; + } +} diff --git a/src/api/java/vazkii/botania/api/internal/DummyPage.java b/src/api/java/vazkii/botania/api/internal/DummyPage.java new file mode 100644 index 0000000..33cbcf8 --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/DummyPage.java @@ -0,0 +1,35 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:41:23 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import vazkii.botania.api.lexicon.LexiconPage; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * A dummy page. It does absolutely nothing and is only + * existant to make sure everything goes right even if + * Botania isn't loaded. + */ +public class DummyPage extends LexiconPage { + + public DummyPage(String unlocalizedName) { + super(unlocalizedName); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderScreen(IGuiLexiconEntry gui, int x, int y) { + // NO-OP + } + +} diff --git a/src/api/java/vazkii/botania/api/internal/DummySubTile.java b/src/api/java/vazkii/botania/api/internal/DummySubTile.java new file mode 100644 index 0000000..d23adce --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/DummySubTile.java @@ -0,0 +1,18 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 24, 2014, 4:17:33 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import vazkii.botania.api.subtile.SubTileEntity; + +public class DummySubTile extends SubTileEntity { + +} diff --git a/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java b/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java new file mode 100644 index 0000000..c8bf6da --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java @@ -0,0 +1,57 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:48:41 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import vazkii.botania.api.lexicon.LexiconEntry; + +/** + * Internal interface for the Lexicon Entry GUI. This contains + * everything that can be accessed from it. It's safe to cast + * this type to GuiScreen. + */ +public interface IGuiLexiconEntry { + + /** + * Gets the entry currently portrayed in this gui. + */ + public LexiconEntry getEntry(); + + /** + * Gets the current page the lexicon GUI is browsing. + */ + public int getPageOn(); + + /** + * Gets the leftmost part of the GUI. + */ + public int getLeft(); + + /** + * Gets the topmost part of the GUI. + */ + public int getTop(); + + /** + * Gets the GUI's width. + */ + public int getWidth(); + + /** + * Gets the GUI's height + */ + public int getHeight(); + + /** + * Gets the GUI's Z level for rendering. + */ + public float getZLevel(); +} diff --git a/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java b/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java new file mode 100644 index 0000000..fa1934a --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java @@ -0,0 +1,79 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:34:34 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import java.util.List; + +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import vazkii.botania.api.lexicon.LexiconPage; +import vazkii.botania.api.recipe.RecipeElvenTrade; +import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RecipePetals; +import vazkii.botania.api.recipe.RecipeRuneAltar; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Any methods that refer to internal methods in Botania are here. + * This is defaulted to a dummy handler, whose methods do nothing. + * This handler is set to a proper one on PreInit. Make sure to + * make your mod load after Botania if you have any intention of + * doing anythign with this on PreInit. + */ +public interface IInternalMethodHandler { + + public LexiconPage textPage(String key); + + public LexiconPage imagePage(String key, String resource); + + public LexiconPage craftingRecipesPage(String key, List recipes); + + public LexiconPage craftingRecipePage(String key, IRecipe recipe); + + public LexiconPage petalRecipesPage(String key, List recipes); + + public LexiconPage petalRecipePage(String key, RecipePetals recipe); + + public LexiconPage runeRecipesPage(String key, List recipes); + + public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe); + + public LexiconPage manaInfusionRecipesPage(String key, List recipes); + + public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe); + + public LexiconPage elvenTradePage(String key, List recipes); + + public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe); + + public IManaNetwork getManaNetworkInstance(); + + public ItemStack getSubTileAsStack(String subTile); + + public IIcon getSubTileIconForName(String name); + + public boolean shouldForceCheck(); + + public IInventory getBaublesInventory(EntityPlayer player); + + @SideOnly(Side.CLIENT) + public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res); + + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); + +} diff --git a/src/api/java/vazkii/botania/api/internal/IManaBurst.java b/src/api/java/vazkii/botania/api/internal/IManaBurst.java new file mode 100644 index 0000000..38c5fd8 --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/IManaBurst.java @@ -0,0 +1,62 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 31, 2014, 4:36:13 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; + +/** + * Interface for the Mana Burst entity. This can safely be casted to EntityThrowable. + */ +public interface IManaBurst { + + public boolean isFake(); + + public void setMotion(double x, double y, double z); + + public int getColor(); + + public void setColor(int color); + + public int getMana(); + + public void setMana(int mana); + + public int getStartingMana(); + + public void setStartingMana(int mana); + + public int getMinManaLoss(); + + public void setMinManaLoss(int minManaLoss); + + public float getManaLossPerTick(); + + public void setManaLossPerTick(float mana); + + public float getGravity(); + + public void setGravity(float gravity); + + public ChunkCoordinates getBurstSourceChunkCoordinates(); + + public void setBurstSourceCoords(int x, int y, int z); + + public ItemStack getSourceLens(); + + public void setSourceLens(ItemStack lens); + + public boolean hasAlreadyCollidedAt(int x, int y, int z); + + public int getTicksExisted(); + +} diff --git a/src/api/java/vazkii/botania/api/internal/IManaNetwork.java b/src/api/java/vazkii/botania/api/internal/IManaNetwork.java new file mode 100644 index 0000000..38e9419 --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/IManaNetwork.java @@ -0,0 +1,68 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 7, 2014, 3:39:48 PM (GMT)] + */ +package vazkii.botania.api.internal; + +import java.util.List; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import vazkii.botania.api.mana.TileSignature; + +/** + * A basic interface for a world's Mana Network. + * @see IInternalMethodHandler#getManaNetworkInstance() + */ +public interface IManaNetwork { + + /** + * Clears the entire Mana Network of all it's contents, you probably + * don't want to call this unless you have a very good reason. + */ + public void clear(); + + /** + * Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk + * Coordinates passed in, in the given dimension.
+ * A way of getting the dimension is via worldObj.provider.dimensionId
+ * Note that this function *can* get performance intensive, it's reccomended you + * call it sparingly and take cache of the value returned. + * @param limit The maximum distance the closest block can be, if the closest block + * is farther away than that, null will be returned instead. + */ + public TileEntity getClosestCollector(ChunkCoordinates pos, World world, int limit); + + /** + * Gets the closest Mana Pool in the network to the Chunk Coordinates passed in, + * in the given dimension.
+ * A way of getting the dimension is via worldObj.provider.dimensionId
+ * Note that this function *can* get performance intensive, it's reccomended you + * call it sparingly and take cache of the value returned. + * @param limit The maximum distance the closest block can be, if the closest block + * is farther away than that, null will be returned instead. + */ + public TileEntity getClosestPool(ChunkCoordinates pos, World world, int limit); + + /** + * Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension + * passed in. Note that this is the actual list and not a copy, make sure to + * clone the list if you intend to change it in any way. + */ + public List getAllCollectorsInWorld(World world); + + /** + * Gets the list of all Mana Pools in the dimension passed in. Note that this + * is the actual list and not a copy, make sure to clone the list if you intend + * to change it in any way. + */ + public List getAllPoolsInWorld(World world); +} diff --git a/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java b/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java new file mode 100644 index 0000000..abe815b --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java @@ -0,0 +1,29 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Aug 6, 2014, 6:02:29 PM (GMT)] + */ +package vazkii.botania.api.item; + +/** + * An interface that defines an instance of PlayerControllerMP with + * the ability to modify reach. See vazkii.botania.client.core.handler.BotaniaPlayerController + */ +public interface IExtendedPlayerController { + + /** + * Sets the extra reach the player should have. + */ + public void setReachDistanceExtension(float f); + + /** + * Gets the current reach extension. + */ + public float getReachDistanceExtension(); +} diff --git a/src/api/java/vazkii/botania/api/item/IPixieSpawner.java b/src/api/java/vazkii/botania/api/item/IPixieSpawner.java new file mode 100644 index 0000000..c0d47f8 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IPixieSpawner.java @@ -0,0 +1,30 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Aug 6, 2014, 6:06:27 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.item.ItemStack; + +/** + * Any item that implements this allows for pixies to be spawned when the player takes damage when...
+ * - Case the item is armor, having it equipped.
+ * - Case the item is a bauble, having it worn.
+ * - On any other case, having the item being the current held item. + */ +public interface IPixieSpawner { + + /** + * The chance this item adds for pixies to be spawned. From 0.0 to 1.0. All values + * are put together when calculating. + */ + public float getPixieChance(ItemStack stack); + +} \ No newline at end of file diff --git a/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java b/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java new file mode 100644 index 0000000..fe2167b --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java @@ -0,0 +1,29 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jun 8, 2014, 7:02:48 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +/** + * Have a LexiconEntry implement this to signify it's an "Addon entry", as + * in, one provided by an Addon. This allows it to draw a subtitle of + * sorts, to prevent the [Mod tag here] nonsense that happened with thaumcraft + * addons. It can also be used for other purposes, such as stating an + * entry is WIP. + */ +public interface IAddonEntry { + + /** + * Returns the unlocalized subtitle to show below the title. Here you'd + * return something like "(This Entry is provided by the Botanic Tinkerer addon)". + */ + public String getSubtitle(); + +} diff --git a/src/api/java/vazkii/botania/api/lexicon/ILexicon.java b/src/api/java/vazkii/botania/api/lexicon/ILexicon.java new file mode 100644 index 0000000..ee07e17 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/ILexicon.java @@ -0,0 +1,21 @@ +package vazkii.botania.api.lexicon; + +import net.minecraft.item.ItemStack; + +/** + * Basic interface for the Lexica Botania. + */ +public interface ILexicon { + + /** + * Gets if a specific knowledge is unlocked. Check the knowledge types in + * BotaniaAPI. + */ + public boolean isKnowledgeUnlocked(ItemStack stack, KnowledgeType knowledge); + + /** + * Unlocks a specfic type of knowledge. + */ + public void unlockKnowledge(ItemStack stack, KnowledgeType knowledge); + +} diff --git a/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java b/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java new file mode 100644 index 0000000..e8777db --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java @@ -0,0 +1,29 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 20, 2014, 7:05:44 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * Any block that implements this can be right clicked with + * a Lexica Botania to open a entry page. + */ +public interface ILexiconable { + + /** + * Gets the lexicon entry to open at this location. null works too. + */ + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon); + +} diff --git a/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java b/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java new file mode 100644 index 0000000..d07c032 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java @@ -0,0 +1,24 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 20, 2014, 6:08:48 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +import net.minecraft.item.ItemStack; + +/** + * Have an Item implement this so that the method used for mapping it into + * the lexicon recipe mappings isn't the typical id:meta key. + */ +public interface IRecipeKeyProvider { + + public String getKey(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/lexicon/KnowledgeType.java b/src/api/java/vazkii/botania/api/lexicon/KnowledgeType.java new file mode 100644 index 0000000..5a08c9c --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/KnowledgeType.java @@ -0,0 +1,20 @@ +package vazkii.botania.api.lexicon; + +import net.minecraft.util.EnumChatFormatting; + +public class KnowledgeType { + + public final String id; + public final EnumChatFormatting color; + public final boolean autoUnlock; + + public KnowledgeType(String id, EnumChatFormatting color, boolean autoUnlock) { + this.id = id; + this.color = color; + this.autoUnlock = autoUnlock; + } + + public String getUnlocalizedName() { + return "botania.knowledge." + id; + } +} diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java b/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java new file mode 100644 index 0000000..7627341 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java @@ -0,0 +1,32 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:23:47 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +import java.util.ArrayList; +import java.util.List; + +public final class LexiconCategory { + + public final String unlocalizedName; + public final List entries = new ArrayList(); + + /** + * @param unlocalizedName The unlocalized name of this category. This will be localized by the client display. + */ + public LexiconCategory(String unlocalizedName) { + this.unlocalizedName = unlocalizedName; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } +} diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java b/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java new file mode 100644 index 0000000..df60cd2 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java @@ -0,0 +1,94 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:17:06 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.util.StatCollector; +import vazkii.botania.api.BotaniaAPI; + +public class LexiconEntry implements Comparable { + + public final String unlocalizedName; + public final LexiconCategory category; + + private KnowledgeType type = BotaniaAPI.basicKnowledge; + + public List pages = new ArrayList(); + private boolean priority = false; + + /** + * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. + */ + public LexiconEntry(String unlocalizedName, LexiconCategory category) { + this.unlocalizedName = unlocalizedName; + this.category = category; + } + + /** + * Sets this page as prioritized, as in, will appear before others in the lexicon. + */ + public LexiconEntry setPriority() { + priority = true; + return this; + } + + /** + * Sets the Knowledge type of this entry. + */ + public LexiconEntry setKnowledgeType(KnowledgeType type) { + this.type = type; + return this; + } + + public KnowledgeType getKnowledgeType() { + return type; + } + + public boolean isPriority() { + return priority; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } + + /** + * Sets what pages you want this entry to have. + */ + public LexiconEntry setLexiconPages(LexiconPage... pages) { + this.pages.addAll(Arrays.asList(pages)); + + for(int i = 0; i < this.pages.size(); i++) + this.pages.get(i).onPageAdded(this, i); + + return this; + } + + /** + * Adds a page to the list of pages. + */ + public void addPage(LexiconPage page) { + pages.add(page); + } + + public final String getNameForSorting() { + return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName()); + } + + @Override + public int compareTo(LexiconEntry o) { + return getNameForSorting().compareTo(o.getNameForSorting()); + } +} \ No newline at end of file diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java b/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java new file mode 100644 index 0000000..4ab7bd7 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java @@ -0,0 +1,53 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 14, 2014, 6:17:24 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +import vazkii.botania.api.internal.IGuiLexiconEntry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class LexiconPage { + + public String unlocalizedName; + + public LexiconPage(String unlocalizedName) { + this.unlocalizedName = unlocalizedName; + } + + /** + * Does the rendering for this page. + * @param gui The active GuiScreen + * @param mx The mouse's relative X position. + * @param my The mouse's relative Y position. + */ + @SideOnly(Side.CLIENT) + public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my); + + /** + * Called per update tick. + */ + @SideOnly(Side.CLIENT) + public void updateScreen() { + // NO-OP + } + + /** + * Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called. + */ + public void onPageAdded(LexiconEntry entry, int index) { + // NO-OP + } + + public String getUnlocalizedName() { + return unlocalizedName; + } +} diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java b/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java new file mode 100644 index 0000000..49b2a13 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java @@ -0,0 +1,66 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 6, 2014, 3:54:12 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +/** + * This class contains mappings for which entry and page correspond to each + * craftable ItemStack. Use the map method to map an ItemStack to a page in + * an entry in the lexicon. + */ +public final class LexiconRecipeMappings { + + private static Map mappings = new HashMap(); + + /** + * Maps the given stack to the given page of the entry. + */ + public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) { + EntryData data = new EntryData(entry, page); + String str = stackToString(stack); + + if(force || !mappings.containsKey(str)) + mappings.put(str, data); + } + + public static void map(ItemStack stack, LexiconEntry entry, int page) { + map(stack, entry, page, false); + } + + + public static EntryData getDataForStack(ItemStack stack) { + return mappings.get(stackToString(stack)); + } + + public static String stackToString(ItemStack stack) { + if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) + return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); + + return stack.getUnlocalizedName() + "~" + stack.getItemDamage(); + } + + public static class EntryData { + + public final LexiconEntry entry; + public final int page; + + public EntryData(LexiconEntry entry, int page) { + this.entry = entry; + this.page = page; + } + + } +} diff --git a/src/api/java/vazkii/botania/api/mana/BurstProperties.java b/src/api/java/vazkii/botania/api/mana/BurstProperties.java new file mode 100644 index 0000000..eed7480 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/BurstProperties.java @@ -0,0 +1,37 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 31, 2014, 3:49:30 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * The properties of a mana burst, when shot. This is passed to the lens + * currently on the mana spreader to apply changes. + */ +public final class BurstProperties { + + public int maxMana; + public int ticksBeforeManaLoss; + public float manaLossPerTick; + public float gravity; + public float motionModifier; + + public int color; + + public BurstProperties(int maxMana, int ticksBeforeManaLoss, float manaLossPerTick, float gravity, float motionModifier, int color) { + this.maxMana = maxMana; + this.ticksBeforeManaLoss = ticksBeforeManaLoss; + this.manaLossPerTick = manaLossPerTick; + this.gravity = gravity; + this.motionModifier = motionModifier; + this.color = color; + } + +} diff --git a/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java b/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java new file mode 100644 index 0000000..889cfb5 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java @@ -0,0 +1,21 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 2, 2014, 5:26:02 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * A TileEntity that implements this will get it's recieveMana call + * called on both client and server. If this is not implemented + * the call will only occur on the server. + */ +public interface IClientManaHandler extends IManaReceiver { + +} diff --git a/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java b/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java new file mode 100644 index 0000000..51f3cce --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [May 25, 2014, 7:34:00 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; + +/** + * Have an item implement this to flag it as an infinite + * mana source for the purposes of the HUD rendered when + * an IManaUserItem implementing item is present. + */ +public interface ICreativeManaProvider { + + public boolean isCreative(ItemStack stack); + +} + diff --git a/src/api/java/vazkii/botania/api/mana/IKeyLocked.java b/src/api/java/vazkii/botania/api/mana/IKeyLocked.java new file mode 100644 index 0000000..a7870e6 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IKeyLocked.java @@ -0,0 +1,30 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 11, 2014, 4:29:32 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * A TileEntity that implements this interface has an IO key lock. This + * interface defines an input and output key.

+ * + * A Spreader can only shoot mana into a IKeyLocked interfaced TE if the Input + * key of the TE is equal to the Output key of the Spreader.

+ * + * A Spreader can only pull mana from a IKeyLocked interfaced IManaPool TE if the + * Output key of the IManaPool is equal to the Input key of the Spreader. + */ +public interface IKeyLocked { + + public String getInputKey(); + + public String getOutputKey(); + +} diff --git a/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java b/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java new file mode 100644 index 0000000..91cb0b9 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java @@ -0,0 +1,23 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 26, 2014, 9:51:58 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.world.World; + +/** + * A block that implements this has a flag for whether it can be moved by the Shard of Laputa. + */ +public interface ILaputaImmobile { + + public boolean canMove(World world, int x, int y, int z); + +} diff --git a/src/api/java/vazkii/botania/api/mana/ILens.java b/src/api/java/vazkii/botania/api/mana/ILens.java new file mode 100644 index 0000000..628d102 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ILens.java @@ -0,0 +1,43 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 31, 2014, 3:03:04 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Have an Item implement this to be counted as a lens for the mana spreader. + */ +public interface ILens extends ILensEffect { + + @SideOnly(Side.CLIENT) + public int getLensColor(ItemStack stack); + + /** + * Can the source lens be combined with the composite lens? This is called + * for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens. + */ + public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens); + + /** + * Gets the composite lens in the stack passed in, return null for none. + */ + public ItemStack getCompositeLens(ItemStack stack); + + /** + * Sets the composite lens for the sourceLens as the compositeLens, returns + * the ItemStack with the combination. + */ + public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens); + +} diff --git a/src/api/java/vazkii/botania/api/mana/ILensEffect.java b/src/api/java/vazkii/botania/api/mana/ILensEffect.java new file mode 100644 index 0000000..d97095b --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ILensEffect.java @@ -0,0 +1,49 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Apr 14, 2014, 7:30:00 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import vazkii.botania.api.internal.IManaBurst; + +/** + * Have an item implement this for it to count as a lens effect and + * be able to change the properties of Mana Bursts. + */ +public interface ILensEffect { + + /** + * Called when a mana spreader that has this focus shoots a burst. This is where + * you change the properties of the burst. + */ + public void apply(ItemStack stack, BurstProperties props); + + /** + * Called when a mana burst fired from a mana spreader with this focus collides against + * any block. This is called after the collision is handled. + * @return True to kill the burst. False to keep it alive. + */ + public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack); + + /** + * Called when a mana burst fired from a mana spreader with this focus is updated. + * This is called before the update is handled. + */ + public void updateBurst(IManaBurst burst, ItemStack stack); + + /** + * Called when the mana burst should do it's particles. Return false to not + * do any particles. + */ + public boolean doParticles(IManaBurst burst, ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaBlock.java b/src/api/java/vazkii/botania/api/mana/IManaBlock.java new file mode 100644 index 0000000..6896f05 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaBlock.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 4:59:05 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * A TileEntity that implements this is considered a Mana Block. + * Just being a Mana Block doesn't mean much, look at the other IMana + * interfaces. + */ +public interface IManaBlock { + + /** + * Gets the amount of mana currently in this block. + */ + public int getCurrentMana(); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaCollector.java b/src/api/java/vazkii/botania/api/mana/IManaCollector.java new file mode 100644 index 0000000..a54d8c9 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaCollector.java @@ -0,0 +1,43 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 5:01:19 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import vazkii.botania.api.internal.IManaBurst; + +/** + * Any TileEntity that implements this is considered a mana collector, by + * which nearby generating flowers will pump mana into it.

+ * + * Implementation Instructions:
+ * - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removeCollector(this); on both.
+ * - On the first tick of onUpdate(), call ManaNetworkEvent.addCollector(this); + */ +public interface IManaCollector extends IManaReceiver { + + /** + * Called every tick on the client case the player is holding a Wand of the Forest. + */ + public void onClientDisplayTick(); + + /** + * Get the multiplier of mana to input into the block, 1.0 is the original amount of mana + * in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get + * dissipated. + */ + public float getManaYieldMultiplier(IManaBurst burst); + + /** + * Gets the maximum amount of mana this collector can have. + */ + public int getMaxMana(); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java b/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java new file mode 100644 index 0000000..420f683 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java @@ -0,0 +1,22 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 10, 2014, 7:49:19 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * Any TileEntity that implements this can be counted as a "ghost" block of + * sorts, that won't call the collision code for the mana bursts. + */ +public interface IManaCollisionGhost { + + public boolean isGhost(); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaItem.java b/src/api/java/vazkii/botania/api/mana/IManaItem.java new file mode 100644 index 0000000..6fdcc22 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaItem.java @@ -0,0 +1,67 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 6, 2014, 9:07:40 AM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +/** + * An item that implements this can be counted as an item that can + * contain mana. + */ +public interface IManaItem { + + /** + * Gets the amount of mana this item contains + */ + public int getMana(ItemStack stack); + + /** + * Gets the max amount of mana this item can hold. + */ + public int getMaxMana(ItemStack stack); + + /** + * Adds mana to this item. + */ + public void addMana(ItemStack stack, int mana); + + /** + * Can this item receive mana from a mana Pool? + * @param pool The pool it's receiving mana from, can be casted to IManaPool. + * @see IManaPool#isOutputtingPower() + */ + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool); + + /** + * Can this item recieve mana from another item? + */ + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack); + + /** + * Can this item export mana to a mana Pool? + * @param pool The pool it's exporting mana to, can be casted to IManaPool. + * @see IManaPool#isOutputtingPower() + */ + public boolean canExportManaToPool(ItemStack stack,TileEntity pool); + + /** + * Can this item export mana to another item? + */ + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack); + + /** + * If this item simply does not export mana in any have, set this to true. + */ + public boolean isNoExport(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaPool.java b/src/api/java/vazkii/botania/api/mana/IManaPool.java new file mode 100644 index 0000000..b93bf6e --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaPool.java @@ -0,0 +1,31 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 5:03:09 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * Any TileEntity that implements this is considered a Mana Pool, + * by which nearby functional flowers will pull mana from it.
+ * Mana Distributors will also accept it as valid output.

+ * + * Implementation Instructions:
+ * - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removePool(this); on both.
+ * - On the first tick of onUpdate(), call ManaNetworkEvent.addPool(this); + */ +public interface IManaPool extends IManaReceiver { + + /** + * Returns false if the mana pool is accepting power from other power items, + * true if it's sending power into them. + */ + public boolean isOutputtingPower(); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaReceiver.java b/src/api/java/vazkii/botania/api/mana/IManaReceiver.java new file mode 100644 index 0000000..2838c7b --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaReceiver.java @@ -0,0 +1,35 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 4:55:00 PM (GMT)] + */ +package vazkii.botania.api.mana; + +/** + * Any TileEntity that implements this can receive mana from mana bursts. + */ +public interface IManaReceiver extends IManaBlock { + + /** + * Is this Mana Receiver is full? Being full means no mana bursts will be sent. + */ + public boolean isFull(); + + /** + * Called when this receiver receives mana. + */ + public void recieveMana(int mana); + + /** + * Can this tile receive mana from bursts? Generally set to false for + * implementations of IManaCollector. + */ + public boolean canRecieveManaFromBursts(); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaTrigger.java b/src/api/java/vazkii/botania/api/mana/IManaTrigger.java new file mode 100644 index 0000000..684a2c1 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaTrigger.java @@ -0,0 +1,24 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [May 16, 2014, 7:52:53 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.world.World; +import vazkii.botania.api.internal.IManaBurst; + +/** + * Have a block implement this class to make it do something when a mana burst collides with it. + */ +public interface IManaTrigger { + + public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java b/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java new file mode 100644 index 0000000..d06cf74 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [May 25, 2014, 7:32:10 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; + +/** + * Any item that implements this interface is an item that would use mana + * from the player's inventory. If there's any items in the inventory or + * equipped in either the baubles or armor inventories that implement + * this interface, a mana bar will be rendered. + */ +public interface IManaUsingItem { + + public boolean usesMana(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java b/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java new file mode 100644 index 0000000..f677c3e --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 2, 2014, 6:36:54 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +/** + * A block that implements this can provide an IIcon (block icons only) + * to be used as an overlay for the mana pool, similarly to the mana void + * and catalysts. + */ +public interface IPoolOverlayProvider { + + public IIcon getIcon(World world, int x, int y, int z); + +} diff --git a/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java b/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java new file mode 100644 index 0000000..004c52e --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java @@ -0,0 +1,24 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 22, 2014, 2:26:14 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; + +/** + * Any Item that implements ILensEffect and this will have + * a check before being pulled by the Tiny Planet. + */ +public interface ITinyPlanetExcempt { + + public boolean shouldPull(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java b/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java new file mode 100644 index 0000000..74fb005 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java @@ -0,0 +1,201 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 13, 2014, 5:32:24 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import vazkii.botania.api.BotaniaAPI; + +public final class ManaItemHandler { + + /** + * Requests mana from items in a given player's inventory. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. + */ + public static int requestMana(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + if(stack == null) + return 0; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItem = (IManaItem) stackInSlot.getItem(); + if(manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) + continue; + + int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot)); + + if(remove) + manaItem.addMana(stackInSlot, -mana); + + return mana; + } + } + } + + return 0; + } + + /** + * Requests an exact amount of mana from items in a given player's inventory. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. + */ + public static boolean requestManaExact(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + if(stack == null) + return false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + if(manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) + continue; + + if(remove) + manaItemSlot.addMana(stackInSlot, -manaToGet); + + return true; + } + } + } + + return false; + } + + /** + * Dispatches mana to items in a given player's inventory. Note that this method + * does not automatically remove mana from the item which is exporting. + * @param manaToSend How much mana is to be sent. + * @param remove If true, the mana will be added from the target item. Set to false to just check. + * @return The amount of mana actually sent. + */ + public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if(stack == null) + return 0; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + + if(manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) + continue; + + int received = 0; + if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) + received = manaToSend; + else received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot)); + + + if(add) + manaItemSlot.addMana(stackInSlot, manaToSend); + + return received; + } + } + } + + return 0; + } + + /** + * Dispatches an exact amount of mana to items in a given player's inventory. Note that this method + * does not automatically remove mana from the item which is exporting. + * @param manaToSend How much mana is to be sent. + * @param remove If true, the mana will be added from the target item. Set to false to just check. + * @return If an item received the mana sent. + */ + public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if(stack == null) + return false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + if(stackInSlot == stack) + continue; + + if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) { + IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); + if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) + continue; + + if(add) + manaItemSlot.addMana(stackInSlot, manaToSend); + + return true; + } + } + } + + return false; + } +} diff --git a/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java b/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java new file mode 100644 index 0000000..e04253a --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java @@ -0,0 +1,57 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 5:04:30 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.eventhandler.Event; + +public class ManaNetworkEvent extends Event { + + public final TileEntity tile; + public final ManaBlockType type; + public final Action action; + + public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) { + this.tile = tile; + this.type = type; + this.action = action; + } + + public static void addCollector(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void removeCollector(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void addPool(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD); + MinecraftForge.EVENT_BUS.post(event); + } + + public static void removePool(TileEntity tile) { + ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE); + MinecraftForge.EVENT_BUS.post(event); + } + + public enum ManaBlockType { + POOL, COLLECTOR + } + + public enum Action { + REMOVE, ADD + } +} diff --git a/src/api/java/vazkii/botania/api/mana/TileSignature.java b/src/api/java/vazkii/botania/api/mana/TileSignature.java new file mode 100644 index 0000000..5573670 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/TileSignature.java @@ -0,0 +1,15 @@ +package vazkii.botania.api.mana; + +import net.minecraft.tileentity.TileEntity; + +public class TileSignature { + + public final TileEntity tile; + public final boolean remoteWorld; + + public TileSignature(TileEntity tile, boolean remoteWorld) { + this.tile = tile; + this.remoteWorld = remoteWorld; + } + +} diff --git a/src/api/java/vazkii/botania/api/package-info.java b/src/api/java/vazkii/botania/api/package-info.java new file mode 100644 index 0000000..e5a7b19 --- /dev/null +++ b/src/api/java/vazkii/botania/api/package-info.java @@ -0,0 +1,4 @@ +@API(owner = "Botania", apiVersion = "7", provides = "BotaniaAPI") +package vazkii.botania.api; +import cpw.mods.fml.common.API; + diff --git a/src/api/java/vazkii/botania/api/recipe/IElvenItem.java b/src/api/java/vazkii/botania/api/recipe/IElvenItem.java new file mode 100644 index 0000000..e614014 --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/IElvenItem.java @@ -0,0 +1,14 @@ +package vazkii.botania.api.recipe; + +import net.minecraft.item.ItemStack; + +/** + * Any Item that implements this is classified as an "Elven Item", by which, + * it'll not go through the alfheim portal. Any item that comes out of it + * must implement this or it'll just go back in. + */ +public interface IElvenItem { + + public boolean isElvenItem(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java b/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java new file mode 100644 index 0000000..fe5bf3c --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Feb 15, 2014, 2:36:35 PM (GMT)] + */ +package vazkii.botania.api.recipe; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +/** + * Have an Item implement this to allow it to be used in the Petal Apothecary. + */ +public interface IFlowerComponent { + + public boolean canFit(ItemStack stack, IInventory apothecary); + + public int getParticleColor(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/recipe/RecipeElvenTrade.java b/src/api/java/vazkii/botania/api/recipe/RecipeElvenTrade.java new file mode 100644 index 0000000..dbea13e --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/RecipeElvenTrade.java @@ -0,0 +1,94 @@ +package vazkii.botania.api.recipe; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class RecipeElvenTrade { + + ItemStack output; + List inputs; + + public RecipeElvenTrade(ItemStack output, Object... inputs) { + this.output = output; + + List inputsToSet = new ArrayList(); + for(Object obj : inputs) { + if(obj instanceof String || obj instanceof ItemStack) + inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(List stacks, boolean remove) { + List inputsMissing = new ArrayList(inputs); + List stacksToRemove = new ArrayList(); + + for(ItemStack stack : stacks) { + if(stack == null) { + continue; + } + if(inputsMissing.isEmpty()) + break; + + int stackIndex = -1, oredictIndex = -1; + + for(int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) { + if(!stacksToRemove.contains(stack)) + stacksToRemove.add(stack); + oredictIndex = j; + found = true; + break; + } + } + + if(found) + break; + } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + if(!stacksToRemove.contains(stack)) + stacksToRemove.add(stack); + stackIndex = j; + break; + } + } + + if(stackIndex != -1) + inputsMissing.remove(stackIndex); + else if(oredictIndex != -1) + inputsMissing.remove(oredictIndex); + } + + if(remove) + for(ItemStack r : stacksToRemove) + stacks.remove(r); + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public ItemStack getOutput() { + return output; + } + +} diff --git a/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java b/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java new file mode 100644 index 0000000..e87b002 --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java @@ -0,0 +1,81 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 30, 2014, 5:57:07 PM (GMT)] + */ +package vazkii.botania.api.recipe; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class RecipeManaInfusion { + + ItemStack output; + Object input; + int mana; + boolean isAlchemy = false; + boolean isConjuration = false; + + public RecipeManaInfusion(ItemStack output, Object input, int mana) { + this.output = output; + this.input = input; + this.mana = mana; + } + + public boolean matches(ItemStack stack) { + if(input instanceof ItemStack) + return stack.isItemEqual((ItemStack) input); + + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) + return true; + } + } + + return false; + } + + public void setAlchemy(boolean alchemy) { + isAlchemy = alchemy; + } + + public boolean isAlchemy() { + return isAlchemy; + } + + public void setConjuration(boolean conjuration) { + isConjuration = conjuration; + } + + public boolean isConjuration() { + return isConjuration; + } + + public Object getInput() { + return input; + } + + public ItemStack getOutput() { + return output; + } + + public int getManaToConsume() { + return mana; + } +} + diff --git a/src/api/java/vazkii/botania/api/recipe/RecipePetals.java b/src/api/java/vazkii/botania/api/recipe/RecipePetals.java new file mode 100644 index 0000000..0dba51a --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/RecipePetals.java @@ -0,0 +1,97 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)] + */ +package vazkii.botania.api.recipe; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class RecipePetals { + + ItemStack output; + List inputs; + + public RecipePetals(ItemStack output, Object... inputs) { + this.output = output; + + List inputsToSet = new ArrayList(); + for(Object obj : inputs) { + if(obj instanceof String || obj instanceof ItemStack) + inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(inputs); + + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack == null) + break; + + int stackIndex = -1, oredictIndex = -1; + + for(int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) { + oredictIndex = j; + found = true; + break; + } + } + + + if(found) + break; + } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + stackIndex = j; + break; + } + } + + if(stackIndex != -1) + inputsMissing.remove(stackIndex); + else if(oredictIndex != -1) + inputsMissing.remove(oredictIndex); + else return false; + } + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public ItemStack getOutput() { + return output; + } + +} diff --git a/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java b/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java new file mode 100644 index 0000000..745c957 --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java @@ -0,0 +1,31 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Feb 5, 2014, 1:41:14 PM (GMT)] + */ +package vazkii.botania.api.recipe; + +import net.minecraft.item.ItemStack; + +public class RecipeRuneAltar extends RecipePetals { + + ItemStack output; + int mana; + + public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) { + super(output, inputs); + this.output = output; + this.mana = mana; + } + + public int getManaUsage() { + return mana; + } + +} diff --git a/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java b/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java new file mode 100644 index 0000000..0ef3149 --- /dev/null +++ b/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java @@ -0,0 +1,21 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 7:12:28 PM (GMT)] + */ +package vazkii.botania.api.subtile; + +/** + * The special flowers in botania implement this. Used for cases where + * BlockFlower would be checked against, but isn't convenient for + * the special flowers with effects. For Azanor and Lycaon. + */ +public interface ISpecialFlower { + +} diff --git a/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java b/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java new file mode 100644 index 0000000..499e385 --- /dev/null +++ b/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java @@ -0,0 +1,111 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 24, 2014, 3:59:06 PM (GMT)] + */ +package vazkii.botania.api.subtile; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IIcon; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.lexicon.LexiconEntry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * A Sub-TileEntity, this is used for the flower system. Make sure to map subclasses + * of this using BotaniaAPI.mapSubTile(String, Class). Any subclass of this must have + * a no parameter constructor. + */ +public class SubTileEntity { + + protected TileEntity supertile; + + /** The Tag items should use to store which sub tile they are. **/ + public static final String TAG_TYPE = "type"; + + public void setSupertile(TileEntity tile) { + supertile = tile; + } + + public boolean canUpdate() { + return false; + } + + public void onUpdate() { } + + /** + * Writes some extra data to a network packet. This data is read + * by readFromPacketNBT on the client that receives the packet. + * Note: This method is also used to write to the world NBT. + */ + public void writeToPacketNBT(NBTTagCompound cmp) { } + + /** + * Reads data from a network packet. This data is written by + * writeToPacketNBT in the server. Note: This method is also used + * to read from the world NBT. + */ + public void readFromPacketNBT(NBTTagCompound cmp) { } + + public void sync() { + supertile.getWorldObj().markBlockForUpdate(supertile.xCoord, supertile.yCoord, supertile.zCoord); + } + + public String getUnlocalizedName() { + return BotaniaAPI.getSubTileStringMapping(getClass()); + } + + /** + * Gets the icon for this SubTileEntity, this is a block icon. + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName()); + } + + /** + * Called when a Wand of the Forest is used on this sub tile. Note that the + * player parameter can be null if this is called from a dispenser. + */ + public boolean onWanded(EntityPlayer player, ItemStack wand) { + return false; + } + + /** + * Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon. + */ + public LexiconEntry getEntry() { + return null; + } + + /** + * Gets the block coordinates this is bound to, for use with the wireframe render + * when the sub tile is being hovered with a wand of the forest. + */ + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding() { + return null; + } + + /** + * Called on the client when the block being pointed at is the one with this sub tile. + * Used to render a HUD portraying some data from this sub tile. + */ + @SideOnly(Side.CLIENT) + public void renderHUD(Minecraft mc, ScaledResolution res) { + // NO-OP + } +} diff --git a/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java b/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java new file mode 100644 index 0000000..a927946 --- /dev/null +++ b/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java @@ -0,0 +1,190 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 24, 2014, 8:03:44 PM (GMT)] + */ +package vazkii.botania.api.subtile; + +import java.awt.Color; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.internal.IManaNetwork; +import vazkii.botania.api.mana.IManaPool; + +/** + * The basic class for a Functional Flower. + */ +public class SubTileFunctional extends SubTileEntity { + + private static final String TAG_MANA = "mana"; + + private static final String TAG_POOL_X = "poolX"; + private static final String TAG_POOL_Y = "poolY"; + private static final String TAG_POOL_Z = "poolZ"; + + public int mana; + + public int redstoneSignal = 0; + + int sizeLastCheck = -1; + TileEntity linkedPool = null; + public int knownMana = -1; + + ChunkCoordinates cachedPoolCoordinates = null; + + @Override + public boolean canUpdate() { + return true; + } + + /** + * If set to true, redstoneSignal will be updated every tick. + */ + public boolean acceptsRedstone() { + return false; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + linkPool(); + + if(linkedPool != null) { + IManaPool pool = (IManaPool) linkedPool; + int manaInPool = pool.getCurrentMana(); + int manaMissing = getMaxMana() - mana; + int manaToRemove = Math.min(manaMissing, manaInPool); + pool.recieveMana(-manaToRemove); + addMana(manaToRemove); + } + + if(acceptsRedstone()) { + redstoneSignal = 0; + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal()); + redstoneSignal = Math.max(redstoneSignal, redstoneSide); + } + } + + if(supertile.getWorldObj().isRemote) { + double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; + Color color = new Color(getColor()); + if(Math.random() > particleChance) + BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); + } + } + + public void linkPool() { + final int range = 10; + + boolean needsNew = false; + if(linkedPool == null) { + needsNew = true; + + if(cachedPoolCoordinates != null && supertile.getWorldObj().blockExists(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ)) { + TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ); + if(tileAt != null && tileAt instanceof IManaPool) { + linkedPool = tileAt; + needsNew = false; + } + cachedPoolCoordinates = null; + } + } + + if(!needsNew) { + TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); + if(!(tileAt instanceof IManaPool)) { + linkedPool = null; + needsNew = true; + } else linkedPool = tileAt; + } + + if(needsNew) { + IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); + int size = network.getAllPoolsInWorld(supertile.getWorldObj()).size(); + if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + linkedPool = network.getClosestPool(coords, supertile.getWorldObj(), range); + sizeLastCheck = size; + } + } + } + + public void addMana(int mana) { + this.mana = Math.min(getMaxMana(), this.mana + mana); + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return false; + + knownMana = mana; + player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + + return super.onWanded(player, wand); + } + + public int getMaxMana() { + return 20; + } + + public int getColor() { + return 0xFFFFFF; + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + + int x = cmp.getInteger(TAG_POOL_X); + int y = cmp.getInteger(TAG_POOL_Y); + int z = cmp.getInteger(TAG_POOL_Z); + + cachedPoolCoordinates = new ChunkCoordinates(x, y, z); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + + int x = linkedPool == null ? 0 : linkedPool.xCoord; + int y = linkedPool == null ? -1 : linkedPool.yCoord; + int z = linkedPool == null ? 0 : linkedPool.zCoord; + + cmp.setInteger(TAG_POOL_X, x); + cmp.setInteger(TAG_POOL_Y, y); + cmp.setInteger(TAG_POOL_Z, z); + } + + @Override + public ChunkCoordinates getBinding() { + if(linkedPool == null) + return null; + return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); + int color = 0x66000000 | getColor(); + BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); + } + +} diff --git a/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java b/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java new file mode 100644 index 0000000..4d86776 --- /dev/null +++ b/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java @@ -0,0 +1,204 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 24, 2014, 8:03:36 PM (GMT)] + */ +package vazkii.botania.api.subtile; + +import java.awt.Color; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.StatCollector; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.internal.IManaNetwork; +import vazkii.botania.api.mana.IManaCollector; + +/** + * The basic class for a Generating Flower. + */ +public class SubTileGenerating extends SubTileEntity { + + private static final String TAG_MANA = "mana"; + + private static final String TAG_COLLECTOR_X = "collectorX"; + private static final String TAG_COLLECTOR_Y = "collectorY"; + private static final String TAG_COLLECTOR_Z = "collectorZ"; + + protected int mana; + + int sizeLastCheck = -1; + protected TileEntity linkedCollector = null; + public int knownMana = -1; + + ChunkCoordinates cachedCollectorCoordinates = null; + + @Override + public boolean canUpdate() { + return true; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + linkCollector(); + + if(canGeneratePassively()) { + int delay = getDelayBetweenPassiveGeneration(); + if(delay > 0 && supertile.getWorldObj().getWorldTime() % delay == 0) { + if(shouldSyncPassiveGeneration()) + sync(); + addMana(getValueForPassiveGeneration()); + } + } + emptyManaIntoCollector(); + + if(supertile.getWorldObj().isRemote) { + double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; + Color color = new Color(getColor()); + if(Math.random() > particleChance) + BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); + } + } + + public void linkCollector() { + final int range = 6; + + boolean needsNew = false; + if(linkedCollector == null) { + needsNew = true; + + if(cachedCollectorCoordinates != null && supertile.getWorldObj().blockExists(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ)) { + TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ); + if(tileAt != null && tileAt instanceof IManaCollector) { + linkedCollector = tileAt; + needsNew = false; + } + cachedCollectorCoordinates = null; + } + } + + if(!needsNew) { + TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); + if(!(tileAt instanceof IManaCollector)) { + linkedCollector = null; + needsNew = true; + } else linkedCollector = tileAt; + } + + if(needsNew) { + IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); + int size = network.getAllCollectorsInWorld(supertile.getWorldObj()).size(); + if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); + linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj(), range); + sizeLastCheck = size; + } + } + } + + public void addMana(int mana) { + this.mana = Math.min(getMaxMana(), this.mana + mana); + } + + public void emptyManaIntoCollector() { + if(linkedCollector != null) { + IManaCollector collector = (IManaCollector) linkedCollector; + if(!collector.isFull() && mana > 0) { + int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana()); + mana -= manaval; + collector.recieveMana(manaval); + sync(); + } + } + } + + public boolean shouldSyncPassiveGeneration() { + return false; + } + + public boolean canGeneratePassively() { + return false; + } + + public int getDelayBetweenPassiveGeneration() { + return 20; + } + + public int getValueForPassiveGeneration() { + return 1; + } + + @Override + public boolean onWanded(EntityPlayer player, ItemStack wand) { + if(player == null) + return false; + + if(!player.worldObj.isRemote) + sync(); + + knownMana = mana; + player.worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F); + + return super.onWanded(player, wand); + } + + public int getMaxMana() { + return 20; + } + + public int getColor() { + return 0xFFFFFF; + } + + @Override + public void readFromPacketNBT(NBTTagCompound cmp) { + mana = cmp.getInteger(TAG_MANA); + + int x = cmp.getInteger(TAG_COLLECTOR_X); + int y = cmp.getInteger(TAG_COLLECTOR_Y); + int z = cmp.getInteger(TAG_COLLECTOR_Z); + + cachedCollectorCoordinates = new ChunkCoordinates(x, y, z); + } + + @Override + public void writeToPacketNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_MANA, mana); + + int x = linkedCollector == null ? 0 : linkedCollector.xCoord; + int y = linkedCollector == null ? -1 : linkedCollector.yCoord; + int z = linkedCollector == null ? 0 : linkedCollector.zCoord; + + cmp.setInteger(TAG_COLLECTOR_X, x); + cmp.setInteger(TAG_COLLECTOR_Y, y); + cmp.setInteger(TAG_COLLECTOR_Z, z); + } + + @Override + public ChunkCoordinates getBinding() { + if(linkedCollector == null) + return null; + return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); + } + + @Override + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); + int color = 0x66000000 | getColor(); + BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); + } + +} diff --git a/src/api/java/vazkii/botania/api/wand/ICoordBoundItem.java b/src/api/java/vazkii/botania/api/wand/ICoordBoundItem.java new file mode 100644 index 0000000..f7c8036 --- /dev/null +++ b/src/api/java/vazkii/botania/api/wand/ICoordBoundItem.java @@ -0,0 +1,18 @@ +package vazkii.botania.api.wand; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * The item equivalent of ITileBound, renders when the + * item is in hand. + * @see ITileBound + */ +public interface ICoordBoundItem { + + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding(ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/wand/ITileBound.java b/src/api/java/vazkii/botania/api/wand/ITileBound.java new file mode 100644 index 0000000..25a8683 --- /dev/null +++ b/src/api/java/vazkii/botania/api/wand/ITileBound.java @@ -0,0 +1,31 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Mar 24, 2014, 6:47:53 PM (GMT)] + */ +package vazkii.botania.api.wand; + +import net.minecraft.util.ChunkCoordinates; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Any TileEntity that implements this is technically bound + * to something, and the binding will be shown when hovering + * over with a Wand of the Forest. + */ +public interface ITileBound { + + /** + * Gets where this block is bound to, can return null. + */ + @SideOnly(Side.CLIENT) + public ChunkCoordinates getBinding(); + +} diff --git a/src/api/java/vazkii/botania/api/wand/IWandHUD.java b/src/api/java/vazkii/botania/api/wand/IWandHUD.java new file mode 100644 index 0000000..57c7e31 --- /dev/null +++ b/src/api/java/vazkii/botania/api/wand/IWandHUD.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Feb 5, 2014, 1:34:44 PM (GMT)] + */ +package vazkii.botania.api.wand; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.world.World; + +/** + * Any block that implements this has a HUD rendered when being hovered + * with a Wand of the Forest. + */ +public interface IWandHUD { + + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z); + +} diff --git a/src/api/java/vazkii/botania/api/wand/IWandable.java b/src/api/java/vazkii/botania/api/wand/IWandable.java new file mode 100644 index 0000000..519745d --- /dev/null +++ b/src/api/java/vazkii/botania/api/wand/IWandable.java @@ -0,0 +1,29 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 22, 2014, 5:12:53 PM (GMT)] + */ +package vazkii.botania.api.wand; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * Any block that implements this can be used with the Wand for the Forest for some purpose. + */ +public interface IWandable { + + /** + * Called when the item is used by a wand. Note that the player parameter can be null + * if this function is called from a dispenser. + */ + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side); + +} diff --git a/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java b/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java new file mode 100644 index 0000000..d20b666 --- /dev/null +++ b/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java @@ -0,0 +1,25 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Apr 19, 2014, 7:23:59 PM (GMT)] + */ +package vazkii.botania.api.wand; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +/** + * A block that implements this can provide a custom AABB + * for rendering the wireframe with ITileBound. + */ +public interface IWireframeAABBProvider { + + public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z); + +}