From be32c6e5a300cca3b48b61b57c916658ce0ee43b Mon Sep 17 00:00:00 2001 From: Jeremy Diamond Date: Wed, 25 Feb 2015 18:10:45 -0800 Subject: [PATCH] Revert "Using the API the right way" This reverts commit 0933e4d23dcda90aff8a41dd76ff44ac36d0759b. --- .../api/ColourAndCoords.java | 45 + .../alchemicalWizardry/api/Int3.java | 44 + .../api/RoutingFocusLogic.java | 16 + .../api/RoutingFocusLogicIgnMeta.java | 12 + .../api/RoutingFocusLogicMatchNBT.java | 17 + .../api/RoutingFocusLogicModItems.java | 21 + .../api/RoutingFocusParadigm.java | 60 ++ .../api/RoutingFocusPosAndFacing.java | 21 + .../AlchemicalPotionCreationHandler.java | 79 ++ .../AlchemyPotionHandlerComponent.java | 52 ++ .../api/alchemy/AlchemyPotionHelper.java | 76 ++ .../api/alchemy/AlchemyRecipe.java | 143 ++++ .../api/alchemy/AlchemyRecipeRegistry.java | 85 ++ .../api/alchemy/energy/IAlchemyGoggles.java | 10 + .../api/alchemy/energy/IReagentContainer.java | 16 + .../api/alchemy/energy/IReagentHandler.java | 18 + .../energy/ISegmentedReagentHandler.java | 14 + .../api/alchemy/energy/Reagent.java | 52 ++ .../api/alchemy/energy/ReagentContainer.java | 153 ++++ .../alchemy/energy/ReagentContainerInfo.java | 19 + .../api/alchemy/energy/ReagentRegistry.java | 174 ++++ .../api/alchemy/energy/ReagentStack.java | 63 ++ .../alchemy/energy/TileReagentHandler.java | 66 ++ .../energy/TileSegmentedReagentHandler.java | 283 ++++++ .../api/altarRecipeRegistry/AltarRecipe.java | 134 +++ .../AltarRecipeRegistry.java | 72 ++ .../api/altarRecipeRegistry/IFadedRune.java | 6 + .../api/bindingRegistry/BindingRecipe.java | 35 + .../api/bindingRegistry/BindingRegistry.java | 67 ++ .../api/compress/CompressionHandler.java | 14 + .../api/compress/CompressionRegistry.java | 67 ++ .../api/event/AddToNetworkEvent.java | 38 + .../api/event/ItemBindEvent.java | 22 + .../api/event/ItemDrainInContainerEvent.java | 15 + .../api/event/ItemDrainNetworkEvent.java | 29 + .../api/event/PlayerAddToNetworkEvent.java | 18 + .../api/event/PlayerDrainNetworkEvent.java | 20 + .../api/event/RitualActivatedEvent.java | 23 + .../api/event/RitualEvent.java | 18 + .../api/event/RitualRunEvent.java | 16 + .../api/event/RitualStopEvent.java | 15 + .../api/event/SoulNetworkEvent.java | 26 + .../api/event/TeleposeEvent.java | 56 ++ .../api/harvest/HarvestRegistry.java | 33 + .../api/harvest/IHarvestHandler.java | 20 + .../api/items/IAltarManipulator.java | 6 + .../api/items/ItemSpellMultiTool.java | 806 ++++++++++++++++++ .../api/items/ShapedBloodOrbRecipe.java | 281 ++++++ .../api/items/ShapelessBloodOrbRecipe.java | 180 ++++ .../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/items/interfaces/ILPGauge.java | 8 + .../items/interfaces/IReagentManipulator.java | 9 + .../api/items/interfaces/IRitualDiviner.java | 14 + .../api/renderer/MRSRenderer.java | 21 + .../api/rituals/IMasterRitualStone.java | 44 + .../api/rituals/IRitualStone.java | 18 + .../api/rituals/ITileRitualStone.java | 6 + .../api/rituals/LocalRitualStorage.java | 42 + .../api/rituals/RitualBreakMethod.java | 11 + .../api/rituals/RitualComponent.java | 71 ++ .../api/rituals/RitualEffect.java | 90 ++ .../api/rituals/Rituals.java | 395 +++++++++ .../soulNetwork/ComplexNetworkHandler.java | 126 +++ .../api/soulNetwork/LifeEssenceNetwork.java | 30 + .../api/soulNetwork/SoulNetworkHandler.java | 458 ++++++++++ .../api/spell/APISpellHelper.java | 325 +++++++ .../api/spell/ComplexSpellEffect.java | 92 ++ .../api/spell/ComplexSpellModifier.java | 9 + .../api/spell/ComplexSpellType.java | 9 + .../api/spell/EntitySpellProjectile.java | 654 ++++++++++++++ .../spell/ExtrapolatedMeleeEntityEffect.java | 72 ++ .../api/spell/IDigAreaEffect.java | 12 + .../api/spell/IItemManipulator.java | 10 + .../api/spell/ILeftClickEffect.java | 9 + .../api/spell/IMeleeSpellEntityEffect.java | 9 + .../api/spell/IMeleeSpellWorldEffect.java | 9 + .../api/spell/IOnBanishTool.java | 10 + .../api/spell/IOnBreakBlock.java | 12 + .../api/spell/IOnSummonTool.java | 10 + .../api/spell/IProjectileImpactEffect.java | 12 + .../api/spell/IProjectileUpdateEffect.java | 8 + .../api/spell/IRightClickEffect.java | 15 + .../api/spell/ISelfSpellEffect.java | 9 + .../api/spell/ISpecialDamageEffect.java | 10 + .../api/spell/IToolUpdateEffect.java | 10 + .../spell/MeleeSpellCenteredWorldEffect.java | 33 + .../api/spell/MeleeSpellWorldEffect.java | 21 + .../api/spell/ProjectileImpactEffect.java | 15 + .../api/spell/ProjectileUpdateEffect.java | 15 + .../api/spell/SelfSpellEffect.java | 15 + .../api/spell/SpellEffect.java | 500 +++++++++++ .../api/spell/SpellEffectRegistry.java | 157 ++++ .../api/spell/SpellEnhancement.java | 20 + .../api/spell/SpellEnhancementCost.java | 10 + .../api/spell/SpellEnhancementPotency.java | 10 + .../api/spell/SpellEnhancementPower.java | 10 + .../api/spell/SpellParadigm.java | 131 +++ .../api/spell/SpellParadigmMelee.java | 70 ++ .../api/spell/SpellParadigmProjectile.java | 101 +++ .../api/spell/SpellParadigmSelf.java | 58 ++ .../api/spell/SpellParadigmTool.java | 485 +++++++++++ .../summoningRegistry/SummoningHelper.java | 21 + .../summoningRegistry/SummoningRegistry.java | 70 ++ .../SummoningRegistryComponent.java | 231 +++++ .../api/tile/IBloodAltar.java | 26 + .../api/tile/ISpellParadigmTile.java | 10 + .../api/tile/ISpellTile.java | 11 + .../java/fox/spiteful/forbidden/Config.java | 6 + .../spiteful/forbidden/FMEventHandler.java | 49 +- .../fox/spiteful/forbidden/Forbidden.java | 5 +- .../spiteful/forbidden/ForbiddenResearch.java | 2 +- .../spiteful/forbidden/compat/BloodMagic.java | 169 ++++ .../fox/spiteful/forbidden/compat/Compat.java | 6 + .../forbidden/compat/ForbiddenBotany.java | 25 + .../forbidden/compat/RitualSanity.java | 135 +++ .../forbidden/items/ForbiddenItems.java | 27 +- .../forbidden/items/ItemDivineOrb.java | 112 +++ .../items/baubles/ItemSubCollar.java | 3 + .../items/scribes/ItemBloodwell.java | 91 ++ .../items/scribes/ItemBoundwell.java | 97 +++ .../items/tools/ItemBloodRapier.java | 86 ++ .../items/wands/BloodStaffUpdate.java | 82 ++ .../items/wands/BloodWandUpdate.java | 67 ++ .../forbidden/items/wands/ItemWandCores.java | 10 + .../forbidden/potions/DarkPotions.java | 38 + .../forbidden/potions/PotionBloodSeal.java | 20 + .../forbidden/tiles/SubTileBloodthorn.java | 69 ++ 130 files changed, 9351 insertions(+), 7 deletions(-) create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/Int3.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogic.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicIgnMeta.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicMatchNBT.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicModItems.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusParadigm.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusPosAndFacing.java 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/alchemy/energy/IAlchemyGoggles.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentContainer.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ISegmentedReagentHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainer.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainerInfo.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileReagentHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.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/altarRecipeRegistry/IFadedRune.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/compress/CompressionHandler.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/AddToNetworkEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/ItemBindEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainInContainerEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainNetworkEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerAddToNetworkEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerDrainNetworkEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/RitualActivatedEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/RitualEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/RitualRunEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/RitualStopEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/SoulNetworkEvent.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/event/TeleposeEvent.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/IAltarManipulator.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.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/items/interfaces/ILPGauge.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IReagentManipulator.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IRitualDiviner.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/renderer/MRSRenderer.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/ITileRitualStone.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualBreakMethod.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/ComplexNetworkHandler.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/spell/APISpellHelper.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellModifier.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellType.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ExtrapolatedMeleeEntityEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IDigAreaEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IItemManipulator.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ILeftClickEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellEntityEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellWorldEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBanishTool.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBreakBlock.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnSummonTool.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileImpactEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileUpdateEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IRightClickEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ISelfSpellEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ISpecialDamageEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellCenteredWorldEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellWorldEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileImpactEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileUpdateEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SelfSpellEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementCost.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPotency.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPower.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.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/WayofTime/alchemicalWizardry/api/tile/ISpellParadigmTile.java create mode 100644 src/api/java/WayofTime/alchemicalWizardry/api/tile/ISpellTile.java create mode 100644 src/main/java/fox/spiteful/forbidden/compat/BloodMagic.java create mode 100644 src/main/java/fox/spiteful/forbidden/compat/RitualSanity.java create mode 100644 src/main/java/fox/spiteful/forbidden/items/ItemDivineOrb.java create mode 100644 src/main/java/fox/spiteful/forbidden/items/scribes/ItemBloodwell.java create mode 100644 src/main/java/fox/spiteful/forbidden/items/scribes/ItemBoundwell.java create mode 100644 src/main/java/fox/spiteful/forbidden/items/tools/ItemBloodRapier.java create mode 100644 src/main/java/fox/spiteful/forbidden/items/wands/BloodStaffUpdate.java create mode 100644 src/main/java/fox/spiteful/forbidden/items/wands/BloodWandUpdate.java create mode 100644 src/main/java/fox/spiteful/forbidden/potions/DarkPotions.java create mode 100644 src/main/java/fox/spiteful/forbidden/potions/PotionBloodSeal.java create mode 100644 src/main/java/fox/spiteful/forbidden/tiles/SubTileBloodthorn.java diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java b/src/api/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java new file mode 100644 index 0000000..d34dd41 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java @@ -0,0 +1,45 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraft.nbt.NBTTagCompound; + +public class ColourAndCoords +{ + public int colourRed; + public int colourGreen; + public int colourBlue; + public int colourIntensity; + + public int xCoord; + public int yCoord; + public int zCoord; + + public ColourAndCoords(int red, int green, int blue, int intensity, int x, int y, int z) + { + this.colourRed = red; + this.colourGreen = green; + this.colourBlue = blue; + this.colourIntensity = intensity; + + this.xCoord = x; + this.yCoord = y; + this.zCoord = z; + } + + public static ColourAndCoords readFromNBT(NBTTagCompound tag) + { + return new ColourAndCoords(tag.getInteger("colourRed"), tag.getInteger("colourGreen"), tag.getInteger("colourBlue"), tag.getInteger("colourIntensity"), tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord")); + } + + public NBTTagCompound writeToNBT(NBTTagCompound tag) + { + tag.setInteger("colourRed", colourRed); + tag.setInteger("colourGreen", colourGreen); + tag.setInteger("colourBlue", colourBlue); + tag.setInteger("colourIntensity", colourIntensity); + tag.setInteger("xCoord", xCoord); + tag.setInteger("yCoord", yCoord); + tag.setInteger("zCoord", zCoord); + + return tag; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/Int3.java b/src/api/java/WayofTime/alchemicalWizardry/api/Int3.java new file mode 100644 index 0000000..16facc0 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/Int3.java @@ -0,0 +1,44 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraft.nbt.NBTTagCompound; + + +public class Int3 +{ + public int xCoord; + public int yCoord; + public int zCoord; + + public Int3(int xCoord, int yCoord, int zCoord) + { + this.xCoord = xCoord; + this.yCoord = yCoord; + this.zCoord = zCoord; + } + + public static Int3 readFromNBT(NBTTagCompound tag) + { + return new Int3(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord")); + } + + public NBTTagCompound writeToNBT(NBTTagCompound tag) + { + tag.setInteger("xCoord", xCoord); + tag.setInteger("yCoord", yCoord); + tag.setInteger("zCoord", zCoord); + + return tag; + } + + @Override + public boolean equals(Object o) + { + return o instanceof Int3 ? ((Int3) o).xCoord == this.xCoord && ((Int3) o).yCoord == this.yCoord && ((Int3) o).zCoord == this.zCoord : false; + } + + @Override + public int hashCode() + { + return this.xCoord + this.yCoord << 8 + this.zCoord << 16; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogic.java b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogic.java new file mode 100644 index 0000000..a3f0a3e --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogic.java @@ -0,0 +1,16 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraft.item.ItemStack; + +public class RoutingFocusLogic +{ + public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack) + { + return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) : false); + } + + public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack) + { + return previous || this.getDefaultMatch(keyStack, checkedStack); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicIgnMeta.java b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicIgnMeta.java new file mode 100644 index 0000000..5a2c5dd --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicIgnMeta.java @@ -0,0 +1,12 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraft.item.ItemStack; + +public class RoutingFocusLogicIgnMeta extends RoutingFocusLogic +{ + @Override + public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack) + { + return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() : false); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicMatchNBT.java b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicMatchNBT.java new file mode 100644 index 0000000..73b81b0 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicMatchNBT.java @@ -0,0 +1,17 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraft.item.ItemStack; + +public class RoutingFocusLogicMatchNBT extends RoutingFocusLogic +{ + public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack) + { + return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) && keyStack.areItemStackTagsEqual(keyStack, checkedStack) : false); + } + + @Override + public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack) + { + return previous && this.getDefaultMatch(keyStack, checkedStack); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicModItems.java b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicModItems.java new file mode 100644 index 0000000..25bd70b --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusLogicModItems.java @@ -0,0 +1,21 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; + +public class RoutingFocusLogicModItems extends RoutingFocusLogic +{ + @Override + public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack) + { + if(keyStack != null && checkedStack != null) + { + UniqueIdentifier keyId = GameRegistry.findUniqueIdentifierFor(keyStack.getItem()); + UniqueIdentifier checkedId = GameRegistry.findUniqueIdentifierFor(checkedStack.getItem()); + return keyId.modId.equals(checkedId.modId); + } + + return false; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusParadigm.java b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusParadigm.java new file mode 100644 index 0000000..8c467e8 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusParadigm.java @@ -0,0 +1,60 @@ +package WayofTime.alchemicalWizardry.api; + +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class RoutingFocusParadigm +{ + public List logicList = new LinkedList(); + + public List locationList = new LinkedList(); + + public int maximumAmount = 0; + + public void addRoutingFocusPosAndFacing(RoutingFocusPosAndFacing facing) + { + locationList.add(facing); + } + + public void addLogic(RoutingFocusLogic logic) + { + logicList.add(logic); + } + + public boolean doesItemMatch(ItemStack keyStack, ItemStack checkedStack) + { + boolean isGood = false; + boolean isFirst = true; + for(RoutingFocusLogic logic : logicList) + { + if(isFirst) + { + isGood = logic.getDefaultMatch(keyStack, checkedStack); + isFirst = false; + continue; + } + isGood = logic.doesItemMatch(isGood, keyStack, checkedStack); + } + + return isGood; + } + + public void clear() + { + logicList.clear(); + locationList.clear(); + maximumAmount = 0; + } + + public void setMaximumAmount(int amt) + { + this.maximumAmount = amt; + } + + public int getMaximumAmount() + { + return this.maximumAmount; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusPosAndFacing.java b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusPosAndFacing.java new file mode 100644 index 0000000..a6ee34a --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/RoutingFocusPosAndFacing.java @@ -0,0 +1,21 @@ +package WayofTime.alchemicalWizardry.api; + +import net.minecraftforge.common.util.ForgeDirection; + +public class RoutingFocusPosAndFacing +{ + public Int3 location; + public ForgeDirection facing; + + public RoutingFocusPosAndFacing(Int3 location, ForgeDirection facing) + { + this.location = location; + this.facing = facing; + } + + @Override + public boolean equals(Object obj) + { + return obj instanceof RoutingFocusPosAndFacing ? facing.equals(((RoutingFocusPosAndFacing)obj).facing) && location.equals(((RoutingFocusPosAndFacing)obj).location) : false; + } +} 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..6af0491 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java @@ -0,0 +1,79 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; + +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..aad27ee --- /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..dfb2459 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java @@ -0,0 +1,85 @@ +package WayofTime.alchemicalWizardry.api.alchemy; + +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +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/alchemy/energy/IAlchemyGoggles.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IAlchemyGoggles.java new file mode 100644 index 0000000..8b3e227 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IAlchemyGoggles.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IAlchemyGoggles +{ + public boolean showIngameHUD(World world, ItemStack stack, EntityPlayer player); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentContainer.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentContainer.java new file mode 100644 index 0000000..804fa72 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentContainer.java @@ -0,0 +1,16 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +public interface IReagentContainer +{ + public ReagentStack getReagent(); + + public int getReagentStackAmount(); + + public int getCapacity(); + + public int fill(ReagentStack resource, boolean doFill); + + public ReagentStack drain(int maxDrain, boolean doDrain); + + public ReagentContainerInfo getInfo(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentHandler.java new file mode 100644 index 0000000..165e9ab --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/IReagentHandler.java @@ -0,0 +1,18 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IReagentHandler +{ + int fill(ForgeDirection from, ReagentStack resource, boolean doFill); + + ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain); + + ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain); + + boolean canFill(ForgeDirection from, Reagent reagent); + + boolean canDrain(ForgeDirection from, Reagent reagent); + + ReagentContainerInfo[] getContainerInfo(ForgeDirection from); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ISegmentedReagentHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ISegmentedReagentHandler.java new file mode 100644 index 0000000..14cb51c --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ISegmentedReagentHandler.java @@ -0,0 +1,14 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import java.util.Map; + +public interface ISegmentedReagentHandler extends IReagentHandler +{ + public int getNumberOfTanks(); + + public int getTanksTunedToReagent(Reagent reagent); + + public void setTanksTunedToReagent(Reagent reagent, int total); + + public Map getAttunedTankMap(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java new file mode 100644 index 0000000..1abbc0b --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java @@ -0,0 +1,52 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +public class Reagent +{ + public final String name; + + public static final int REAGENT_SIZE = 1000; + + private int colourRed = 0; + private int colourGreen = 0; + private int colourBlue = 0; + private int colourIntensity = 255; + + public Reagent(String name) + { + this.name = name; + } + + public void setColour(int red, int green, int blue, int intensity) + { + this.colourRed = red; + this.colourGreen = green; + this.colourBlue = blue; + this.colourIntensity = intensity; + } + + public int getColourRed() + { + return colourRed; + } + + public int getColourGreen() + { + return colourGreen; + } + + public int getColourBlue() + { + return colourBlue; + } + + public int getColourIntensity() + { + return colourIntensity; + } + + @Override + public boolean equals(Object o) + { + return o instanceof Reagent ? this == o && name.equals(((Reagent) o).name) : false; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainer.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainer.java new file mode 100644 index 0000000..c135274 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainer.java @@ -0,0 +1,153 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import net.minecraft.nbt.NBTTagCompound; + +public class ReagentContainer implements IReagentContainer +{ + protected ReagentStack reagentStack; + protected int capacity; + + public ReagentContainer(int capacity) + { + this(null, capacity); + } + + public ReagentContainer(ReagentStack stack, int capacity) + { + this.reagentStack = stack; + this.capacity = capacity; + } + + public ReagentContainer(Reagent reagent, int amount, int capacity) + { + this(new ReagentStack(reagent, amount), capacity); + } + + public static ReagentContainer readFromNBT(NBTTagCompound nbt) + { + ReagentStack reagent = ReagentStack.loadReagentStackFromNBT(nbt); + int capacity = nbt.getInteger("capacity"); + + if (reagent != null) + { + return new ReagentContainer(reagent, capacity); + } else + { + return new ReagentContainer(null, capacity); + } + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) + { + if (reagentStack != null) + { + reagentStack.writeToNBT(nbt); + } + + nbt.setInteger("capacity", capacity); + + return nbt; + } + + @Override + public ReagentStack getReagent() + { + return reagentStack; + } + + @Override + public int getReagentStackAmount() + { + if (reagentStack == null) + { + return 0; + } + return reagentStack.amount; + } + + @Override + public int getCapacity() + { + return capacity; + } + + @Override + public int fill(ReagentStack resource, boolean doFill) + { + if (resource == null) + { + return 0; + } + + if (!doFill) + { + if (reagentStack == null) + { + return Math.min(capacity, resource.amount); + } + + if (!reagentStack.isReagentEqual(resource)) + { + return 0; + } + + return Math.min(capacity - reagentStack.amount, resource.amount); + } + + if (reagentStack == null) + { + reagentStack = new ReagentStack(resource, Math.min(capacity, resource.amount)); + + return reagentStack.amount; + } + + if (!reagentStack.isReagentEqual(resource)) + { + return 0; + } + int filled = capacity - reagentStack.amount; + + if (resource.amount < filled) + { + reagentStack.amount += resource.amount; + filled = resource.amount; + } else + { + reagentStack.amount = capacity; + } + + return filled; + } + + @Override + public ReagentStack drain(int maxDrain, boolean doDrain) + { + if (reagentStack == null) + { + return null; + } + + int drained = maxDrain; + if (reagentStack.amount < drained) + { + drained = reagentStack.amount; + } + + ReagentStack stack = new ReagentStack(reagentStack, drained); + if (doDrain) + { + reagentStack.amount -= drained; + if (reagentStack.amount <= 0) + { + reagentStack = null; + } + } + return stack; + } + + @Override + public ReagentContainerInfo getInfo() + { + return new ReagentContainerInfo(this); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainerInfo.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainerInfo.java new file mode 100644 index 0000000..99521dc --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentContainerInfo.java @@ -0,0 +1,19 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +public final class ReagentContainerInfo +{ + public final ReagentStack reagent; + public final int capacity; + + public ReagentContainerInfo(ReagentStack reagent, int capacity) + { + this.reagent = reagent; + this.capacity = capacity; + } + + public ReagentContainerInfo(IReagentContainer tank) + { + this.reagent = tank.getReagent(); + this.capacity = tank.getCapacity(); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java new file mode 100644 index 0000000..20b4393 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java @@ -0,0 +1,174 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.item.ItemStack; + +public class ReagentRegistry +{ + public static Map reagentList = new HashMap(); + public static Map itemToReagentMap = new HashMap(); + + public static Reagent sanctusReagent; + public static Reagent incendiumReagent; + public static Reagent aquasalusReagent; + public static Reagent magicalesReagent; + public static Reagent aetherReagent; + public static Reagent crepitousReagent; + public static Reagent crystallosReagent; + public static Reagent terraeReagent; + public static Reagent tenebraeReagent; + + public static Reagent offensaReagent; + public static Reagent praesidiumReagent; + public static Reagent orbisTerraeReagent; + public static Reagent virtusReagent; + public static Reagent reductusReagent; + public static Reagent potentiaReagent; + + public static void initReagents() + { + sanctusReagent = new Reagent("sanctus"); + incendiumReagent = new Reagent("incendium"); + aquasalusReagent = new Reagent("aquasalus"); + magicalesReagent = new Reagent("magicales"); + aetherReagent = new Reagent("aether"); + crepitousReagent = new Reagent("crepitous"); + crystallosReagent = new Reagent("crystallos"); + terraeReagent = new Reagent("terrae"); + tenebraeReagent = new Reagent("tenebrae"); + offensaReagent = new Reagent("offensa"); + praesidiumReagent = new Reagent("praesidium"); + orbisTerraeReagent = new Reagent("orbisTerrae"); + virtusReagent = new Reagent("virtus"); + reductusReagent = new Reagent("reductus"); + potentiaReagent = new Reagent("potentia"); + + sanctusReagent.setColour(255, 255, 0, 255); + incendiumReagent.setColour(255, 0, 0, 255); + aquasalusReagent.setColour(0, 0, 255, 255); + magicalesReagent.setColour(150, 0, 146, 255); + aetherReagent.setColour(105, 223, 86, 255); + crepitousReagent.setColour(145, 145, 145, 255); + crystallosReagent.setColour(135, 255, 231, 255); + terraeReagent.setColour(147, 48, 13, 255); + tenebraeReagent.setColour(86, 86, 86, 255); + offensaReagent.setColour(126, 0, 0, 255); + praesidiumReagent.setColour(135, 135, 135, 255); + orbisTerraeReagent.setColour(32, 94, 14, 255); + virtusReagent.setColour(180, 0, 0, 255); + reductusReagent.setColour(20, 93, 2, 255); + potentiaReagent.setColour(64, 81, 208, 255); + + registerReagent("sanctus", sanctusReagent); + registerReagent("incendium", incendiumReagent); + registerReagent("aquasalus", aquasalusReagent); + registerReagent("magicales", magicalesReagent); + registerReagent("aether", aetherReagent); + registerReagent("crepitous", crepitousReagent); + registerReagent("crystallos", crystallosReagent); + registerReagent("terrae", terraeReagent); + registerReagent("tenebrae", tenebraeReagent); + registerReagent("offensa", offensaReagent); + registerReagent("praesidium", praesidiumReagent); + registerReagent("orbisTerrae", orbisTerraeReagent); + registerReagent("virtus", virtusReagent); + registerReagent("reductus", reductusReagent); + registerReagent("potentia", potentiaReagent); + } + + public static boolean registerReagent(String key, Reagent reagent) + { + if (reagentList.containsKey(key) || reagent == null) + { + return false; + } + + reagentList.put(key, reagent); + + return true; + } + + public static Reagent getReagentForKey(String key) + { + if (reagentList.containsKey(key)) + { + return reagentList.get(key); + } + + return null; + } + + public static String getKeyForReagent(Reagent reagent) + { + if (reagentList.containsValue(reagent)) + { + Set> set = reagentList.entrySet(); + for (Entry entry : set) + { + if (entry.getValue().equals(reagent)) + { + return entry.getKey(); + } + } + } + + return ""; + } + + public static void registerItemAndReagent(ItemStack stack, ReagentStack reagentStack) + { + itemToReagentMap.put(stack, reagentStack); + } + + public static ReagentStack getReagentStackForItem(ItemStack stack) + { + if (stack == null) + { + return null; + } + + for (Entry entry : itemToReagentMap.entrySet()) + { + if (entry.getKey() != null && entry.getKey().isItemEqual(stack)) + { + if (entry.getValue() == null) + { + return null; + } else + { + return entry.getValue().copy(); + } + } + } + + return null; + } + + public static ItemStack getItemForReagent(Reagent reagent) + { + if (reagent == null) + { + return null; + } + + for (Entry entry : itemToReagentMap.entrySet()) + { + if (entry.getValue() != null && entry.getValue().reagent == reagent) + { + if (entry.getKey() == null) + { + return null; + } else + { + return entry.getKey().copy(); + } + } + } + + return null; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java new file mode 100644 index 0000000..f858397 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java @@ -0,0 +1,63 @@ +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import net.minecraft.nbt.NBTTagCompound; + +public class ReagentStack +{ + public Reagent reagent; + public int amount; + + public ReagentStack(Reagent reagent, int amount) + { + this.reagent = reagent; + this.amount = amount; + } + + public ReagentStack(ReagentStack reagentStack, int amount) + { + this(reagentStack.reagent, amount); + } + + public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag) + { + Reagent reagent = ReagentRegistry.getReagentForKey(tag.getString("Reagent")); + + if (reagent == null) + { + return null; + } + + int amount = tag.getInteger("amount"); + ReagentStack stack = new ReagentStack(reagent, amount); + + return stack; + } + + public NBTTagCompound writeToNBT(NBTTagCompound tag) + { + tag.setString("Reagent", ReagentRegistry.getKeyForReagent(this.reagent)); + tag.setInteger("amount", this.amount); + + return tag; + } + + public ReagentStack splitStack(int amount) + { + ReagentStack copyStack = this.copy(); + int splitAmount = Math.min(amount, this.amount); + copyStack.amount = splitAmount; + this.amount -= splitAmount; + + return copyStack; + } + + public ReagentStack copy() + { + return new ReagentStack(this.reagent, this.amount); + } + + public boolean isReagentEqual(ReagentStack other) + { + return other != null && this.reagent == other.reagent; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileReagentHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileReagentHandler.java new file mode 100644 index 0000000..3e75464 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileReagentHandler.java @@ -0,0 +1,66 @@ + +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileReagentHandler extends TileEntity implements IReagentHandler +{ + protected ReagentContainer tank = new ReagentContainer(4000); + + @Override + public void readFromNBT(NBTTagCompound tag) + { + super.readFromNBT(tag); + tank.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) + { + super.writeToNBT(tag); + tank.writeToNBT(tag); + } + + /* IReagentHandler */ + @Override + public int fill(ForgeDirection from, ReagentStack resource, boolean doFill) + { + return tank.fill(resource, doFill); + } + + @Override + public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain) + { + if (resource == null || !resource.isReagentEqual(tank.getReagent())) + { + return null; + } + return tank.drain(resource.amount, doDrain); + } + + @Override + public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return tank.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Reagent reagent) + { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Reagent reagent) + { + return true; + } + + @Override + public ReagentContainerInfo[] getContainerInfo(ForgeDirection from) + { + return new ReagentContainerInfo[]{tank.getInfo()}; + } +} \ No newline at end of file diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java new file mode 100644 index 0000000..a088b8a --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java @@ -0,0 +1,283 @@ + +package WayofTime.alchemicalWizardry.api.alchemy.energy; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +public class TileSegmentedReagentHandler extends TileEntity implements ISegmentedReagentHandler +{ + protected ReagentContainer[] tanks; + protected Map attunedTankMap; + + public TileSegmentedReagentHandler() + { + this(1); + } + + public TileSegmentedReagentHandler(int numberOfTanks) + { + this(numberOfTanks, 1000); + } + + public TileSegmentedReagentHandler(int numberOfTanks, int tankSize) + { + super(); + + this.attunedTankMap = new HashMap(); + this.tanks = new ReagentContainer[numberOfTanks]; + for (int i = 0; i < numberOfTanks; i++) + { + this.tanks[i] = new ReagentContainer(tankSize); + } + } + + @Override + public void readFromNBT(NBTTagCompound tag) + { + super.readFromNBT(tag); + + NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND); + + int size = tagList.tagCount(); + this.tanks = new ReagentContainer[size]; + + for (int i = 0; i < size; i++) + { + NBTTagCompound savedTag = tagList.getCompoundTagAt(i); + this.tanks[i] = ReagentContainer.readFromNBT(savedTag); + } + + NBTTagList attunedTagList = tag.getTagList("attunedTankMap", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < attunedTagList.tagCount(); i++) + { + NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i); + Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent")); + this.attunedTankMap.put(reagent, savedTag.getInteger("amount")); + } + } + + @Override + public void writeToNBT(NBTTagCompound tag) + { + super.writeToNBT(tag); + + NBTTagList tagList = new NBTTagList(); + + for (int i = 0; i < this.tanks.length; i++) + { + NBTTagCompound savedTag = new NBTTagCompound(); + if (this.tanks[i] != null) + { + this.tanks[i].writeToNBT(savedTag); + } + tagList.appendTag(savedTag); + } + + tag.setTag("reagentTanks", tagList); + + NBTTagList attunedTagList = new NBTTagList(); + + for (Entry entry : this.attunedTankMap.entrySet()) + { + NBTTagCompound savedTag = new NBTTagCompound(); + savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey())); + savedTag.setInteger("amount", entry.getValue()); + attunedTagList.appendTag(savedTag); + } + + tag.setTag("attunedTankMap", attunedTagList); + } + + /* ISegmentedReagentHandler */ + @Override + public int fill(ForgeDirection from, ReagentStack resource, boolean doFill) + { + int totalFill = 0; + + boolean useTankLimit = !this.attunedTankMap.isEmpty(); + + if (resource != null) + { + int totalTanksFillable = useTankLimit ? this.getTanksTunedToReagent(resource.reagent) : this.tanks.length; + int tanksFilled = 0; + + int maxFill = resource.amount; + + for (int i = this.tanks.length - 1; i >= 0; i--) + { + ReagentStack remainingStack = resource.copy(); + remainingStack.amount = maxFill - totalFill; + + boolean doesReagentMatch = tanks[i].getReagent() == null ? false : tanks[i].getReagent().isReagentEqual(remainingStack); + + if (doesReagentMatch) + { + totalFill += tanks[i].fill(remainingStack, doFill); + tanksFilled++; + } else + { + continue; + } + + if (totalFill >= maxFill || tanksFilled >= totalTanksFillable) + { + return totalFill; + } + } + + if (tanksFilled >= totalTanksFillable) + { + return totalFill; + } + + for (int i = this.tanks.length - 1; i >= 0; i--) + { + ReagentStack remainingStack = resource.copy(); + remainingStack.amount = maxFill - totalFill; + + boolean isTankEmpty = tanks[i].getReagent() == null; + + if (isTankEmpty) + { + totalFill += tanks[i].fill(remainingStack, doFill); + tanksFilled++; + } else + { + continue; + } + + if (totalFill >= maxFill || tanksFilled >= totalTanksFillable) + { + return totalFill; + } + } + } + return totalFill; + } + + @Override + public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain) + { + if (resource == null) + { + return null; + } + + int maxDrain = resource.amount; + Reagent reagent = resource.reagent; + int drained = 0; + + for (int i = 0; i < tanks.length; i++) + { + if (drained >= maxDrain) + { + break; + } + + if (resource.isReagentEqual(tanks[i].getReagent())) + { + ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain); + if (drainStack != null) + { + drained += drainStack.amount; + } + } + } + + return new ReagentStack(reagent, drained); + } + + /* Only returns the amount from the first available tank */ + @Override + public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + for (int i = 0; i < tanks.length; i++) + { + ReagentStack stack = tanks[i].drain(maxDrain, doDrain); + if (stack != null) + { + return stack; + } + } + + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Reagent reagent) + { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Reagent reagent) + { + return true; + } + + @Override + public ReagentContainerInfo[] getContainerInfo(ForgeDirection from) + { + ReagentContainerInfo[] info = new ReagentContainerInfo[this.getNumberOfTanks()]; + for (int i = 0; i < this.getNumberOfTanks(); i++) + { + info[i] = tanks[i].getInfo(); + } + return info; + } + + @Override + public int getNumberOfTanks() + { + return tanks.length; + } + + @Override + public int getTanksTunedToReagent(Reagent reagent) + { + if (this.attunedTankMap.containsKey(reagent) && this.attunedTankMap.get(reagent) != null) + { + return this.attunedTankMap.get(reagent); + } + return 0; + } + + @Override + public void setTanksTunedToReagent(Reagent reagent, int total) + { + if (total == 0 && this.attunedTankMap.containsKey(reagent)) + { + this.attunedTankMap.remove(reagent); + return; + } + + this.attunedTankMap.put(reagent, new Integer(total)); + } + + @Override + public Map getAttunedTankMap() + { + return this.attunedTankMap; + } + + public boolean areTanksEmpty() + { + for (int i = 0; i < this.tanks.length; i++) + { + if (tanks[i] != null && tanks[i].reagentStack != null) + { + return false; + } + } + + return true; + } +} \ No newline at end of file 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..fab96be --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java @@ -0,0 +1,134 @@ +package WayofTime.alchemicalWizardry.api.altarRecipeRegistry; + +import java.util.Set; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; + +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 boolean useTag; + + public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled) + { + this(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled, false); + } + + public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled, boolean useTag) + { + this.result = result; + this.requiredItem = requiredItem; + this.minTier = minTier; + this.liquidRequired = liquidRequired; + this.consumptionRate = consumptionRate; + this.drainRate = drainRate; + this.canBeFilled = canBeFilled; + this.useTag = useTag; + } + + 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) && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true); + } + + public boolean areRequiredTagsEqual(ItemStack comparedStack) + { + if(requiredItem.hasTagCompound()) + { + NBTTagCompound tag = requiredItem.getTagCompound(); + if(!comparedStack.hasTagCompound()) + { + return false; + } + + NBTTagCompound comparedTag = comparedStack.getTagCompound(); + + return this.areTagsEqual(tag, comparedTag); + } + + return true; + } + + protected boolean areTagsEqual(NBTTagCompound tag, NBTTagCompound comparedTag) + { + Set set = tag.func_150296_c(); + + for(Object obj : set) + { + if(obj instanceof String) + { + String str = (String)obj; + + NBTBase baseTag = comparedTag.getTag(str); + + if(baseTag instanceof NBTTagCompound) + { + NBTBase comparedBaseTag = comparedTag.getTag(str); + if(comparedBaseTag instanceof NBTTagCompound) + { + if(!this.areTagsEqual((NBTTagCompound) tag, comparedTag)) + { + return false; + } + } + }else + { + if(baseTag != null && !baseTag.equals(comparedTag.getTag(str))) + { + return false; + } + } + } + } + + return true; + } + + 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..e8426d1 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipeRegistry.java @@ -0,0 +1,72 @@ +package WayofTime.alchemicalWizardry.api.altarRecipeRegistry; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +public class AltarRecipeRegistry +{ + public static List altarRecipes = new LinkedList(); + public static Map orbMap = new HashMap(); + + 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 registerNBTAltarRecipe(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, true)); + } + + public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate) + { + if(!orbMap.containsKey(minTier)) + { + orbMap.put(minTier, orbStack); + } + 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/altarRecipeRegistry/IFadedRune.java b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/IFadedRune.java new file mode 100644 index 0000000..9f685d5 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/IFadedRune.java @@ -0,0 +1,6 @@ +package WayofTime.alchemicalWizardry.api.altarRecipeRegistry; + +public interface IFadedRune +{ + public int getAltarTierLimit(int meta); +} 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..fc0ba2d --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRecipe.java @@ -0,0 +1,35 @@ +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(ItemStack inputItem) + { + return this.getResult(); + } + + 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..ba06911 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java @@ -0,0 +1,67 @@ +package WayofTime.alchemicalWizardry.api.bindingRegistry; + +import net.minecraft.item.ItemStack; + +import java.util.LinkedList; +import java.util.List; + +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(testItem).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/compress/CompressionHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/compress/CompressionHandler.java new file mode 100644 index 0000000..a05c700 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/compress/CompressionHandler.java @@ -0,0 +1,14 @@ +package WayofTime.alchemicalWizardry.api.compress; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public abstract class CompressionHandler +{ + /** + * Called to look at the inventory and syphons the required stack. Returns resultant stack if successful, and null if not. + * @param inv The inventory iterated through + * @return The result of the compression + */ + public abstract ItemStack compressInventory(ItemStack[] inv, World world); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java new file mode 100644 index 0000000..fd17c8b --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java @@ -0,0 +1,67 @@ +package WayofTime.alchemicalWizardry.api.compress; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * A registry aimed to help compress items in an inventory into its compressible form. + * + */ +public class CompressionRegistry +{ + public static List compressionRegistry = new ArrayList(); + public static Map thresholdMap = new HashMap(); + + public static void registerHandler(CompressionHandler handler) + { + compressionRegistry.add(handler); + } + + /** + * Registers an item so that it only compresses while above this threshold + * @param stack + * @param threshold + */ + public static void registerItemThreshold(ItemStack stack, int threshold) + { + thresholdMap.put(stack, new Integer(threshold)); + } + + public static ItemStack compressInventory(ItemStack[] inv, World world) + { + for(CompressionHandler handler : compressionRegistry) + { + ItemStack stack = handler.compressInventory(inv, world); + if(stack != null) + { + return stack; + } + } + + return null; + } + + public static int getItemThreshold(ItemStack stack) + { + for(Entry entry : thresholdMap.entrySet()) + { + if(areItemStacksEqual(entry.getKey(), stack)) + { + return entry.getValue(); + } + } + + return 0; + } + + public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) + { + return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound())); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/AddToNetworkEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/AddToNetworkEvent.java new file mode 100644 index 0000000..ddcc3b0 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/AddToNetworkEvent.java @@ -0,0 +1,38 @@ +package WayofTime.alchemicalWizardry.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + +@Cancelable +public class AddToNetworkEvent extends Event +{ + public String ownerNetwork; + public int addedAmount; + public int maximum; + + /** + * This event is called whenever the network is added to. If cancelled, no LP will be drained from the source. If result is set to Result.DENY, + * the LP will still be drained but the soul network will not be added to. + * + * @param ownerNetwork Key used for the soul network + * @param addedAmount Amount added + * @param maximum Ceiling that the network can add to + */ + public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) + { + super(); + this.ownerNetwork = ownerNetwork; + this.addedAmount = addedAmount; + this.maximum = maximum; + } + + public String getOwnerNetwork() + { + return this.ownerNetwork; + } + + public int getAddedAmount() + { + return this.addedAmount; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemBindEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemBindEvent.java new file mode 100644 index 0000000..95e15da --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemBindEvent.java @@ -0,0 +1,22 @@ +package WayofTime.alchemicalWizardry.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.Event; + +@Cancelable +public class ItemBindEvent extends Event +{ + public final EntityPlayer player; + public String key; + public ItemStack itemStack; + + public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) + { + super(); + this.player = player; + this.key = key; + this.itemStack = itemStack; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainInContainerEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainInContainerEvent.java new file mode 100644 index 0000000..5a81c1d --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainInContainerEvent.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.event; + +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.Cancelable; + +@Cancelable +public class ItemDrainInContainerEvent extends SoulNetworkEvent +{ + public ItemStack stack; + public ItemDrainInContainerEvent(ItemStack stack, String ownerNetwork, int drainAmount) + { + super(ownerNetwork, drainAmount); + this.stack = stack; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainNetworkEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainNetworkEvent.java new file mode 100644 index 0000000..d75fd7d --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/ItemDrainNetworkEvent.java @@ -0,0 +1,29 @@ +package WayofTime.alchemicalWizardry.api.event; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.Cancelable; + +@Cancelable +public class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent +{ + public final ItemStack itemStack; + public boolean shouldDamage; //If true, will damage regardless of if the network had enough inside it + public float damageAmount; //Amount of damage that would incur if the network could not drain properly + + /** + * Set result to deny the action i.e. damage/drain anyways. Cancelling event prevents action without penalties + * + * @param player Player using the item + * @param ownerNetwork Network that the item is tied to + * @param itemStack Item used + * @param drainAmount Original drain amount - change to alter cost + */ + public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount) + { + super(player, ownerNetwork, drainAmount); + this.itemStack = itemStack; + this.shouldDamage = false; + this.damageAmount = (float)(drainAmount) / 100.0f; + } +} \ No newline at end of file diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerAddToNetworkEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerAddToNetworkEvent.java new file mode 100644 index 0000000..f752255 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerAddToNetworkEvent.java @@ -0,0 +1,18 @@ +package WayofTime.alchemicalWizardry.api.event; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.Cancelable; + +@Cancelable +public class PlayerAddToNetworkEvent extends AddToNetworkEvent +{ + public final EntityPlayer player; + public ItemStack itemStack; + public PlayerAddToNetworkEvent(EntityPlayer player, ItemStack itemStack, String ownerNetwork, int addedAmount, int maximum) + { + super(ownerNetwork, addedAmount, maximum); + this.player = player; + this.itemStack = itemStack; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerDrainNetworkEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerDrainNetworkEvent.java new file mode 100644 index 0000000..dacb26d --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/PlayerDrainNetworkEvent.java @@ -0,0 +1,20 @@ +package WayofTime.alchemicalWizardry.api.event; + +import net.minecraft.entity.player.EntityPlayer; +import cpw.mods.fml.common.eventhandler.Cancelable; + +@Cancelable +public class PlayerDrainNetworkEvent extends SoulNetworkEvent +{ + public final EntityPlayer player; //Player that activated the event + public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) + { + super(ownerNetwork, drainAmount); + this.player = player; + } + + public EntityPlayer getPlayer() + { + return player; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualActivatedEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualActivatedEvent.java new file mode 100644 index 0000000..83c10c0 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualActivatedEvent.java @@ -0,0 +1,23 @@ +package WayofTime.alchemicalWizardry.api.event; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; +import cpw.mods.fml.common.eventhandler.Cancelable; + +@Cancelable +public class RitualActivatedEvent extends RitualEvent +{ + public final EntityPlayer player; + public final ItemStack crystalStack; + public int crystalTier; + + public RitualActivatedEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey, EntityPlayer player, ItemStack activationCrystal, int crystalTier) + { + super(mrs, ownerKey, ritualKey); + + this.player = player; + this.crystalStack = activationCrystal; + this.crystalTier = crystalTier; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualEvent.java new file mode 100644 index 0000000..fbe1649 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualEvent.java @@ -0,0 +1,18 @@ +package WayofTime.alchemicalWizardry.api.event; + +import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; +import cpw.mods.fml.common.eventhandler.Event; + +public class RitualEvent extends Event +{ + public final IMasterRitualStone mrs; + public String ownerKey; + public final String ritualKey; + + public RitualEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey) + { + this.mrs = mrs; + this.ownerKey = ownerKey; + this.ritualKey = ritualKey; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualRunEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualRunEvent.java new file mode 100644 index 0000000..4bcf075 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualRunEvent.java @@ -0,0 +1,16 @@ +package WayofTime.alchemicalWizardry.api.event; + +import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; +import cpw.mods.fml.common.eventhandler.Cancelable; + +@Cancelable +public class RitualRunEvent extends RitualEvent +{ + + + public RitualRunEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey) + { + super(mrs, ownerKey, ritualKey); + } + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualStopEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualStopEvent.java new file mode 100644 index 0000000..4fc998f --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/RitualStopEvent.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.event; + +import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; +import WayofTime.alchemicalWizardry.api.rituals.RitualBreakMethod; + +public class RitualStopEvent extends RitualEvent +{ + public final RitualBreakMethod method; + public RitualStopEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey, RitualBreakMethod method) + { + super(mrs, ownerKey, ritualKey); + + this.method = method; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/SoulNetworkEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/SoulNetworkEvent.java new file mode 100644 index 0000000..bf47a13 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/SoulNetworkEvent.java @@ -0,0 +1,26 @@ +package WayofTime.alchemicalWizardry.api.event; + +import cpw.mods.fml.common.eventhandler.Event; + +public class SoulNetworkEvent extends Event +{ + public String ownerNetwork; + public int drainAmount; + + public SoulNetworkEvent(String ownerNetwork, int drainAmount) + { + super(); + this.ownerNetwork = ownerNetwork; + this.drainAmount = drainAmount; + } + + public String getOwnerNetwork() + { + return this.ownerNetwork; + } + + public int getDrainAmount() + { + return this.drainAmount; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/event/TeleposeEvent.java b/src/api/java/WayofTime/alchemicalWizardry/api/event/TeleposeEvent.java new file mode 100644 index 0000000..40c3170 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/event/TeleposeEvent.java @@ -0,0 +1,56 @@ +package WayofTime.alchemicalWizardry.api.event; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + +/** Fired when a teleposer attempts to transpose two blocks. Use this to perform special cleanup or compensation, +or cancel it entirely to prevent the transposition. */ +@Cancelable +public class TeleposeEvent extends Event { + + public final World initialWorld; + public final int initialX; + public final int initialY; + public final int initialZ; + + public final Block initialBlock; + public final int initialMetadata; + + public final World finalWorld; + public final int finalX; + public final int finalY; + public final int finalZ; + + public final Block finalBlock; + public final int finalMetadata; + + public TeleposeEvent(World wi, int xi, int yi, int zi, Block bi, int mi, World wf, int xf, int yf, int zf, Block bf, int mf) { + initialWorld = wi; + initialX = xi; + initialY = yi; + initialZ = zi; + + initialBlock = bi; + initialMetadata = mi; + + finalWorld = wf; + finalX = xf; + finalY = yf; + finalZ = zf; + + finalBlock = bf; + finalMetadata = mf; + } + + public TileEntity getInitialTile() { + return initialWorld.getTileEntity(initialX, initialY, initialZ); + } + + public TileEntity getFinalTile() { + return finalWorld.getTileEntity(finalX, finalY, finalZ); + } + +} 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..aac57f5 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java @@ -0,0 +1,33 @@ +package WayofTime.alchemicalWizardry.api.harvest; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; + +public class HarvestRegistry +{ + public static List handlerList = new ArrayList(); + + public static void registerHarvestHandler(IHarvestHandler handler) + { + 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..d5e479d --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/harvest/IHarvestHandler.java @@ -0,0 +1,20 @@ +package WayofTime.alchemicalWizardry.api.harvest; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +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/IAltarManipulator.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/IAltarManipulator.java new file mode 100644 index 0000000..b84f95c --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/IAltarManipulator.java @@ -0,0 +1,6 @@ +package WayofTime.alchemicalWizardry.api.items; + +public interface IAltarManipulator +{ + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java new file mode 100644 index 0000000..93ed96f --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java @@ -0,0 +1,806 @@ +package WayofTime.alchemicalWizardry.api.items; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.common.util.ForgeDirection; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; +import WayofTime.alchemicalWizardry.api.spell.APISpellHelper; +import WayofTime.alchemicalWizardry.api.spell.SpellEffect; +import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool; + +public class ItemSpellMultiTool extends Item +{ + private static final String harvestLevelSuffix = "harvestLvl"; + private static final String digLevelSuffix = "digLvl"; + private static final String tagName = "BloodMagicTool"; + private Random rand = new Random(); + + public ItemSpellMultiTool() + { + super(); + this.setMaxDamage(0); + this.setMaxStackSize(1); + this.setFull3D(); + } + + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundTool"); + } + + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) + { + float damage = this.getCustomItemAttack(par1ItemStack); + + SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack); + + if (parad != null) + { + parad.onLeftClickEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase); + } + + damage += parad.getAddedDamageForEntity(par2EntityLivingBase); + + if (rand.nextFloat() < this.getCritChance(par1ItemStack)) + { + damage *= 1.75f; + } + + if (par3EntityLivingBase instanceof EntityPlayer) + { + par2EntityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), damage); + } else + { + par2EntityLivingBase.attackEntityFrom(DamageSource.causeMobDamage(par3EntityLivingBase), damage); + } + + return true; + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + SpellParadigmTool parad = this.loadParadigmFromStack(stack); + + if (parad != null && entity instanceof EntityLivingBase) + { + parad.onLeftClickEntity(stack, (EntityLivingBase) entity, player); + } + + return false; + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) + { + if (player.worldObj.isRemote) + { + return false; + } + + if (!stack.hasTagCompound()) + return false; + + World world = player.worldObj; + Block block = player.worldObj.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + if (block == null || block == Blocks.air) + return false; + int hlvl = -1; + float blockHardness = block.getBlockHardness(world, x, y, z); + + MovingObjectPosition mop = APISpellHelper.raytraceFromEntity(world, player, true, 5.0D); + + Block localBlock = world.getBlock(x, y, z); + int localMeta = world.getBlockMetadata(x, y, z); + String toolClass = block.getHarvestTool(meta); + if (toolClass != null && this.getHarvestLevel(stack, toolClass) != -1) + hlvl = block.getHarvestLevel(meta); + int toolLevel = this.getHarvestLevel(stack, toolClass); + + float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z); + + if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness) + { + boolean cancelHarvest = false; + + if (!cancelHarvest) + { + if (localBlock != null && !(localHardness < 0)) + { + boolean isEffective = false; + + String localToolClass = this.getToolClassForMaterial(localBlock.getMaterial()); + + if (localToolClass != null && this.getHarvestLevel(stack, toolClass) >= localBlock.getHarvestLevel(localMeta)) + { + isEffective = true; + } + + + if (localBlock.getMaterial().isToolNotRequired()) + { + isEffective = true; + } + + if (!player.capabilities.isCreativeMode) + { + if (isEffective) + { + if (localBlock.removedByPlayer(world, player, x, y, z)) + { + localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta); + } + localBlock.onBlockHarvested(world, x, y, z, localMeta, player); + if (blockHardness > 0f) + onBlockDestroyed(stack, world, localBlock, x, y, z, player); + + List items = APISpellHelper.getItemsFromBlock(world, localBlock, x, y, z, localMeta, this.getSilkTouch(stack), this.getFortuneLevel(stack)); + + SpellParadigmTool parad = this.loadParadigmFromStack(stack); + List newItems = parad.handleItemList(stack, items); + + if (!world.isRemote) + { + APISpellHelper.spawnItemListInWorld(newItems, world, x + 0.5f, y + 0.5f, z + 0.5f); + } + + world.func_147479_m(x, y, z); + + int cost = 0; + + cost += parad.digSurroundingArea(stack, world, player, mop, localToolClass, localHardness, toolLevel, this); + + cost += parad.onBreakBlock(stack, world, player, localBlock, localMeta, x, y, z, ForgeDirection.getOrientation(mop.sideHit)); + + if (cost > 0) + { + SoulNetworkHandler.syphonAndDamageFromNetwork(stack, player, cost); + } + } else + { + world.setBlockToAir(x, y, z); + world.func_147479_m(x, y, z); + } + + } else + { + world.setBlockToAir(x, y, z); + world.func_147479_m(x, y, z); + } + } + } + } + + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + return true; + + } + + public Material[] getMaterialsForToolclass(String toolClass) + { + if ("pickaxe".equals(toolClass)) + { + return new Material[]{Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.circuits}; + } else if ("shovel".equals(toolClass)) + { + return new Material[]{Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay}; + } else if ("axe".equals(toolClass)) + { + return new Material[]{Material.wood, Material.vine, Material.circuits, Material.cactus}; + } + return new Material[0]; + } + + public String getToolClassForMaterial(Material mat) + { + String testString = "pickaxe"; + + Material[] matList = this.getMaterialsForToolclass(testString); + for (int i = 0; i < matList.length; i++) + { + if (matList[i] == mat) + { + return testString; + } + } + + testString = "shovel"; + matList = this.getMaterialsForToolclass(testString); + for (int i = 0; i < matList.length; i++) + { + if (matList[i] == mat) + { + return testString; + } + } + + testString = "axe"; + matList = this.getMaterialsForToolclass(testString); + for (int i = 0; i < matList.length; i++) + { + if (matList[i] == mat) + { + return testString; + } + } + + return null; + } + + public Set getToolClasses(ItemStack stack) + { + Set set = new HashSet(); + + if (this.getHarvestLevel(stack, "pickaxe") > -1) + { + set.add("pickaxe"); + } + + if (this.getHarvestLevel(stack, "axe") > -1) + { + set.add("axe"); + } + + if (this.getHarvestLevel(stack, "shovel") > -1) + { + set.add("shovel"); + } + + return set; + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) + { + String toolClass = block.getHarvestTool(meta); + + if (toolClass == null || toolClass.equals("")) + { + return 1.0f; + } + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + return tag.getFloat(digLevelSuffix + toolClass); + } else + { + stack.setTagCompound(new NBTTagCompound()); + } + } + + return 1.0f; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + if (tag.hasKey(harvestLevelSuffix + toolClass)) + { + return tag.getInteger(harvestLevelSuffix + toolClass); + } else + { + return -1; + } + } else + { + stack.setTagCompound(new NBTTagCompound()); + } + + return -1; + } + + @Override + public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) + { + + return true; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return false; + } + + @Override + public void onUpdate(ItemStack toolStack, World world, Entity par3Entity, int par4, boolean par5) + { + if (world.isRemote) + { + return; + } + + SpellParadigmTool parad = this.loadParadigmFromStack(toolStack); + int cost = parad.onUpdate(toolStack, world, par3Entity, par4, par5); + + if (par3Entity instanceof EntityPlayer && cost > 0) + SoulNetworkHandler.syphonAndDamageFromNetwork(toolStack, (EntityPlayer) par3Entity, cost); + + int duration = Math.max(this.getDuration(toolStack, world), 0); + + if (duration <= 0 && par3Entity instanceof EntityPlayer) + { + int banishCost = parad.onBanishTool(toolStack, world, par3Entity, par4, par5); + SoulNetworkHandler.syphonAndDamageFromNetwork(toolStack, (EntityPlayer) par3Entity, banishCost); + ((EntityPlayer) par3Entity).inventory.mainInventory[par4] = this.getContainedCrystal(toolStack); + } + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par3EntityPlayer.isSneaking()) + { + par3EntityPlayer.setCurrentItemOrArmor(0, this.getContainedCrystal(par1ItemStack)); + return par1ItemStack; + } + + SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack); + + MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false); + + int cost = 0; + + if (mop != null && mop.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK)) + { + cost = parad.onRightClickBlock(par1ItemStack, par3EntityPlayer, par2World, mop); + } else + { + cost = parad.onRightClickAir(par1ItemStack, par2World, par3EntityPlayer); + } + + if (cost > 0) + { + SoulNetworkHandler.syphonAndDamageFromNetwork(par1ItemStack, par3EntityPlayer, cost); + } + + return par1ItemStack; + } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + par3List.add("A mace filled with ancient alchemy"); + + if (!(par1ItemStack.getTagCompound() == null)) + { + if (!par1ItemStack.getTagCompound().getString("ownerName").equals("")) + { + par3List.add("Current owner: " + par1ItemStack.getTagCompound().getString("ownerName")); + } + + for (String str : this.getToolListString(par1ItemStack)) + { + par3List.add(str); + } + + par3List.add(""); + float damage = this.getCustomItemAttack(par1ItemStack); + par3List.add("\u00A79+" + ((int) (damage * 10)) / 10.0f + " " + "Attack Damage"); + float critChance = ((int) (this.getCritChance(par1ItemStack) * 1000)) / 10.0f; + par3List.add("\u00A79+" + critChance + "% " + "Crit Chance"); + } + } + + //--------------Custom methods--------------// + + public void setHarvestLevel(ItemStack stack, String toolClass, int harvestLevel) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setInteger(harvestLevelSuffix + toolClass, Math.max(-1, harvestLevel)); + + stack.getTagCompound().setTag(tagName, tag); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setInteger(harvestLevelSuffix + toolClass, Math.max(-1, harvestLevel)); + + stack.getTagCompound().setTag(tagName, tag); + } + } + + public void setDigSpeed(ItemStack stack, String toolClass, float digSpeed) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setFloat(digLevelSuffix + toolClass, digSpeed); + + stack.getTagCompound().setTag(tagName, tag); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setFloat(digLevelSuffix + toolClass, digSpeed); + + stack.getTagCompound().setTag(tagName, tag); + } + } + + public float getDigSpeed(ItemStack stack, String toolClass) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + return tag.getFloat(digLevelSuffix + toolClass); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + return 0.0f; + } + } + + public void setItemAttack(ItemStack stack, float damage) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setFloat("itemAttack", Math.max(damage, 0.0f)); + + stack.getTagCompound().setTag(tagName, tag); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setFloat("itemAttack", Math.max(damage, 0.0f)); + + stack.getTagCompound().setTag(tagName, tag); + } + } + + public float getCustomItemAttack(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + return tag.getFloat("itemAttack"); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + return 0.0f; + } + } + + public ItemStack getContainedCrystal(ItemStack container) + { + if (container.hasTagCompound()) + { + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName).getCompoundTag("heldItem"); + + return ItemStack.loadItemStackFromNBT(tag); + } else + { + container.setTagCompound(new NBTTagCompound()); + + return null; + } + } + + public void setContainedCrystal(ItemStack container, ItemStack crystal) + { + if (container.hasTagCompound()) + { + NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName); + NBTTagCompound tag = compTag.getCompoundTag("heldItem"); + + crystal.writeToNBT(tag); + + compTag.setTag("heldItem", tag); + container.getTagCompound().setTag(tagName, compTag); + } else + { + container.setTagCompound(new NBTTagCompound()); + + NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName); + NBTTagCompound tag = compTag.getCompoundTag("heldItem"); + + crystal.writeToNBT(tag); + + compTag.setTag("heldItem", tag); + container.getTagCompound().setTag(tagName, compTag); + } + } + + public void setDuration(ItemStack container, World world, int duration) + { + if (world.isRemote) + { + return; + } else + { + World overWorld = DimensionManager.getWorld(0); + long worldtime = overWorld.getTotalWorldTime(); + + if (container.hasTagCompound()) + { + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + + tag.setLong("duration", Math.max(duration + worldtime, worldtime)); + + container.getTagCompound().setTag(tagName, tag); + } else + { + container.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + + tag.setLong("duration", Math.max(duration + worldtime, worldtime)); + + container.getTagCompound().setTag(tagName, tag); + } + } + } + + public int getDuration(ItemStack container, World world) + { + if (world.isRemote) + { + return 0; + } else + { + World overWorld = DimensionManager.getWorld(0); + long worldtime = overWorld.getTotalWorldTime(); + + if (container.hasTagCompound()) + { + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + + return (int) (tag.getLong("duration") - worldtime); + } else + { + container.setTagCompound(new NBTTagCompound()); + + return 0; + } + } + } + + public void loadParadigmIntoStack(ItemStack container, List list) + { + if (!container.hasTagCompound()) + { + container.setTagCompound(new NBTTagCompound()); + } + + NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName); + + NBTTagList effectList = new NBTTagList(); + + for (SpellEffect eff : list) + { + effectList.appendTag(eff.getTag()); + } + + tagiest.setTag("Effects", effectList); + + container.getTagCompound().setTag(tagName, tagiest); + } + + public SpellParadigmTool loadParadigmFromStack(ItemStack container) + { + if (!container.hasTagCompound()) + { + container.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName); + + NBTTagList tagList = tagiest.getTagList("Effects", Constants.NBT.TAG_COMPOUND); + + List spellEffectList = new LinkedList(); + for (int i = 0; i < tagList.tagCount(); i++) + { + NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); + + SpellEffect eff = SpellEffect.getEffectFromTag(tag); + if (eff != null) + { + spellEffectList.add(eff); + } + } + + return SpellParadigmTool.getParadigmForEffectArray(spellEffectList); + } + + public void setSilkTouch(ItemStack stack, boolean silkTouch) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setBoolean("silkTouch", silkTouch); + + stack.getTagCompound().setTag(tagName, tag); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setBoolean("silkTouch", silkTouch); + + stack.getTagCompound().setTag(tagName, tag); + } + } + + public boolean getSilkTouch(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + return tag.getBoolean("silkTouch"); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + return false; + } + } + + public void setFortuneLevel(ItemStack stack, int fortune) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setInteger("fortuneLevel", Math.max(fortune, 0)); + + stack.getTagCompound().setTag(tagName, tag); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + tag.setInteger("fortuneLevel", Math.max(fortune, 0)); + + stack.getTagCompound().setTag(tagName, tag); + } + } + + public int getFortuneLevel(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName); + + return tag.getInteger("fortuneLevel"); + } else + { + stack.setTagCompound(new NBTTagCompound()); + + return 0; + } + } + + public List getToolListString(ItemStack container) + { + if (!container.hasTagCompound()) + { + container.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName); + + NBTTagList tagList = tagiest.getTagList("ToolTips", Constants.NBT.TAG_COMPOUND); + + List toolTipList = new LinkedList(); + for (int i = 0; i < tagList.tagCount(); i++) + { + NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); + + String str = tag.getString("tip"); + if (str != null) + { + toolTipList.add(str); + } + } + + return toolTipList; + } + + public void setToolListString(ItemStack container, List toolTipString) + { + if (!container.hasTagCompound()) + { + container.setTagCompound(new NBTTagCompound()); + } + + NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName); + + NBTTagList stringList = new NBTTagList(); + + for (String str : toolTipString) + { + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("tip", str); + + stringList.appendTag(tag); + } + + tagiest.setTag("ToolTips", stringList); + + container.getTagCompound().setTag(tagName, tagiest); + } + + public void setCritChance(ItemStack container, float chance) + { + if (container.hasTagCompound()) + { + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + + tag.setFloat("critChance", Math.max(chance, 0)); + + container.getTagCompound().setTag(tagName, tag); + } else + { + container.setTagCompound(new NBTTagCompound()); + + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + + tag.setFloat("critChance", Math.max(chance, 0)); + + container.getTagCompound().setTag(tagName, tag); + } + } + + public float getCritChance(ItemStack container) + { + if (container.hasTagCompound()) + { + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + + return tag.getFloat("critChance"); + } else + { + container.setTagCompound(new NBTTagCompound()); + + return 0; + } + } +} \ No newline at end of file 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..6e5b0f9 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java @@ -0,0 +1,281 @@ +package WayofTime.alchemicalWizardry.api.items; + +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; +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 java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +/** + * 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..86bbb56 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java @@ -0,0 +1,180 @@ +package WayofTime.alchemicalWizardry.api.items; + +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; +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 java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * 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 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 ItemStack) + { + if (((ItemStack)in).getItem() instanceof IBloodOrb) + { + input.add((Integer) (((IBloodOrb) ((ItemStack)in).getItem()).getOrbLevel())); + } + else input.add(((ItemStack) in).copy()); + } 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; + match = true; + } 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..e88e9cc --- /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..4150abe --- /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/items/interfaces/ILPGauge.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/ILPGauge.java new file mode 100644 index 0000000..7607023 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/ILPGauge.java @@ -0,0 +1,8 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +import net.minecraft.item.ItemStack; + +public interface ILPGauge +{ + public boolean canSeeLPBar(ItemStack itemStack); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IReagentManipulator.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IReagentManipulator.java new file mode 100644 index 0000000..23ac780 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IReagentManipulator.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +/** + * Implement this interface to have reagent blocks return false on activating them, to allow manipulation of said block + */ +public interface IReagentManipulator +{ + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IRitualDiviner.java b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IRitualDiviner.java new file mode 100644 index 0000000..03094a8 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/items/interfaces/IRitualDiviner.java @@ -0,0 +1,14 @@ +package WayofTime.alchemicalWizardry.api.items.interfaces; + +import net.minecraft.item.ItemStack; + +public interface IRitualDiviner { + int cycleDirection(ItemStack stack); + String getCurrentRitual(ItemStack stack); + int getDirection(ItemStack stack); + int getMaxRuneDisplacement(ItemStack stack); + String getNameForDirection(int direction); + void setCurrentRitual(ItemStack stack, String ritualID); + void setDirection(ItemStack stack, int direction); + void setMaxRuneDisplacement(ItemStack stack, int displacement); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/renderer/MRSRenderer.java b/src/api/java/WayofTime/alchemicalWizardry/api/renderer/MRSRenderer.java new file mode 100644 index 0000000..7eea34c --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/renderer/MRSRenderer.java @@ -0,0 +1,21 @@ +package WayofTime.alchemicalWizardry.api.renderer; + +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.util.ResourceLocation; +import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; + +public abstract class MRSRenderer +{ + public abstract void renderAt(IMasterRitualStone tile, double x, double y, double z); + + protected void bindTexture(ResourceLocation p_147499_1_) + { + TextureManager texturemanager = TileEntityRendererDispatcher.instance.field_147553_e; + + if (texturemanager != null) + { + texturemanager.bindTexture(p_147499_1_); + } + } +} 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..0866677 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IMasterRitualStone.java @@ -0,0 +1,44 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import WayofTime.alchemicalWizardry.api.alchemy.energy.ISegmentedReagentHandler; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public interface IMasterRitualStone extends ISegmentedReagentHandler +{ + 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(); + + public NBTTagCompound getCustomRitualTag(); + + public void setCustomRitualTag(NBTTagCompound tag); + + public boolean areTanksEmpty(); + + public int getRunningTime(); + + public LocalRitualStorage getLocalStorage(); + + public void setLocalStorage(LocalRitualStorage storage); +} 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..c2cec51 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/IRitualStone.java @@ -0,0 +1,18 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import net.minecraft.world.World; + +public interface IRitualStone +{ + /** + * x, y, and z give the position of the Ritual Stone + * @param world + * @param x + * @param y + * @param z + * @param meta + * @param runeType + * @return + */ + public boolean isRuneType(World world, int x, int y, int z, int meta, int runeType); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/ITileRitualStone.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/ITileRitualStone.java new file mode 100644 index 0000000..7204515 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/ITileRitualStone.java @@ -0,0 +1,6 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +public interface ITileRitualStone +{ + public boolean isRuneType(int runeType); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java new file mode 100644 index 0000000..e5a3241 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java @@ -0,0 +1,42 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import net.minecraft.nbt.NBTTagCompound; +import WayofTime.alchemicalWizardry.api.Int3; + +/** + * This class is used to pass ritual-specific data into the RitualEffect from the containing Master Ritual Stone. This is basically used as auxillarary storage, + * for when simply storing to NBT becomes... difficult. + * + */ +public class LocalRitualStorage +{ + public int xCoord; + public int yCoord; + public int zCoord; + + public void writeToNBT(NBTTagCompound tag) + { + tag.setInteger("xCoord", xCoord); + tag.setInteger("yCoord", yCoord); + tag.setInteger("zCoord", zCoord); + } + + public void readFromNBT(NBTTagCompound tag) + { + this.xCoord = tag.getInteger("xCoord"); + this.yCoord = tag.getInteger("yCoord"); + this.zCoord = tag.getInteger("zCoord"); + } + + public Int3 getLocation() + { + return new Int3(xCoord, yCoord, zCoord); + } + + public void setLocation(Int3 location) + { + this.xCoord = location.xCoord; + this.yCoord = location.yCoord; + this.zCoord = location.zCoord; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualBreakMethod.java b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualBreakMethod.java new file mode 100644 index 0000000..a705056 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualBreakMethod.java @@ -0,0 +1,11 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +public enum RitualBreakMethod +{ + REDSTONE, + BREAK_MRS, + BREAK_STONE, + ACTIVATE, //When an activation crystal activates the MRS, overwriting the current ritual + DEACTIVATE, + EXPLOSION, //When the MRS is destroyed by an explosion +} 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..6e896e0 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java @@ -0,0 +1,71 @@ +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 getX(int direction) + { + switch(direction) + { + case 2: + return -this.getZ(); + case 3: + return -this.getX(); + case 4: + return this.getZ(); + default: return this.getX(); + } + } + + public int getZ(int direction) + { + switch(direction) + { + case 2: + return this.getX(); + case 3: + return -this.getZ(); + case 4: + return -this.getX(); + default: return this.getZ(); + } + } + + public int getStoneType() + { + return this.stoneType; + } +} \ No newline at end of file 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..85f291c --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/RitualEffect.java @@ -0,0 +1,90 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; +import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; +import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack; + +public abstract class RitualEffect +{ + public abstract void performEffect(IMasterRitualStone ritualStone); + + public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player) + { + return true; + } + + public void onRitualBroken(IMasterRitualStone ritualStone, RitualBreakMethod method) + { + + } + + public abstract int getCostPerRefresh(); + + public int getInitialCooldown() + { + return 0; + } + + public abstract List getRitualComponentList(); + + public boolean canDrainReagent(IMasterRitualStone ritualStone, Reagent reagent, int amount, boolean doDrain) + { + if (ritualStone == null || reagent == null || amount == 0) + { + return false; + } + + ReagentStack reagentStack = new ReagentStack(reagent, amount); + + ReagentStack stack = ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, false); + + if (stack != null && stack.amount >= amount) + { + if (doDrain) + { + ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, true); + } + + return true; + } + + return false; + } + + public LocalRitualStorage getNewLocalStorage() + { + return new LocalRitualStorage(); + } + + public void addOffsetRunes(ArrayList ritualList, int off1, int off2, int y, int rune) + { + ritualList.add(new RitualComponent(off1, y, off2, rune)); + ritualList.add(new RitualComponent(off2, y, off1, rune)); + ritualList.add(new RitualComponent(off1, y, -off2, rune)); + ritualList.add(new RitualComponent(-off2, y, off1, rune)); + ritualList.add(new RitualComponent(-off1, y, off2, rune)); + ritualList.add(new RitualComponent(off2, y, -off1, rune)); + ritualList.add(new RitualComponent(-off1, y, -off2, rune)); + ritualList.add(new RitualComponent(-off2, y, -off1, rune)); + } + + public void addCornerRunes(ArrayList ritualList, int off1, int y, int rune) + { + ritualList.add(new RitualComponent(off1, y, off1, rune)); + ritualList.add(new RitualComponent(off1, y, -off1, rune)); + ritualList.add(new RitualComponent(-off1, y, -off1, rune)); + ritualList.add(new RitualComponent(-off1, y, off1, rune)); + } + + public void addParallelRunes(ArrayList ritualList, int off1, int y, int rune) + { + ritualList.add(new RitualComponent(off1, y, 0, rune)); + ritualList.add(new RitualComponent(-off1, y, 0, rune)); + ritualList.add(new RitualComponent(0, y, -off1, rune)); + ritualList.add(new RitualComponent(0, y, off1, rune)); + } +} 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..a4d4f66 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java @@ -0,0 +1,395 @@ +package WayofTime.alchemicalWizardry.api.rituals; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import WayofTime.alchemicalWizardry.api.event.RitualRunEvent; +import WayofTime.alchemicalWizardry.api.event.RitualStopEvent; +import WayofTime.alchemicalWizardry.api.renderer.MRSRenderer; +import cpw.mods.fml.common.eventhandler.Event; + +public class Rituals +{ + public final int crystalLevel; + public final int actCost; + public final RitualEffect effect; + public final String name; + + public final MRSRenderer customRenderer; + + public static Map ritualMap = new HashMap(); + public static List keyList = new LinkedList(); + + public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer) + { + this.crystalLevel = crystalLevel; + this.actCost = actCost; + this.effect = effect; + this.name = name; + keyList.add(name); + ritualMap.put(name, this); + this.customRenderer = renderer; + } + + public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name) + { + this(crystalLevel, actCost, effect, name, null); + } + + /** + * 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, MRSRenderer renderer) + { + if (ritualMap.containsKey(key)) + { + return false; + } else + { + Rituals ritual = new Rituals(crystalLevel, actCost, effect, name, renderer); + ritual.removeRitualFromList(); + ritualMap.put(key, ritual); + keyList.add(key); + return true; + } + } + + 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; + TileEntity te = null; + + for (RitualComponent rc : ritual) + { + test = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); + te = world.getTileEntity(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); + + if (!(test instanceof IRitualStone && ((IRitualStone)test).isRuneType(world, x + rc.getX(direction), y, z+ rc.getZ(direction), world.getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)), rc.getStoneType())) + && !(te instanceof ITileRitualStone && ((ITileRitualStone)te).isRuneType(rc.getStoneType()))) + { + return false; + } + } + + return true; + } + + 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; + } + + private MRSRenderer getRenderer() + { + return this.customRenderer; + } + + public static void performEffect(IMasterRitualStone ritualStone, String ritualID) + { + String ownerName = ritualStone.getOwner(); + + RitualRunEvent event = new RitualRunEvent(ritualStone, ownerName, ritualID); + + if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) + { + return; + } + + if (ritualMap.containsKey(event.ritualKey)) + { + Rituals ritual = ritualMap.get(event.ritualKey); + if (ritual != null && ritual.effect != null) + { + ritual.effect.performEffect(ritualStone); + } + } + } + + public static boolean startRitual(IMasterRitualStone ritualStone, String ritualID, EntityPlayer player) + { + if (ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if (ritual != null && ritual.effect != null) + { + return ritual.effect.startRitual(ritualStone, player); + } + } + + return false; + } + + public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID, RitualBreakMethod method) + { + String ownerName = ritualStone.getOwner(); + RitualStopEvent event = new RitualStopEvent(ritualStone, ownerName, ritualID, method); + MinecraftForge.EVENT_BUS.post(event); + + if (ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if (ritual != null && ritual.effect != null) + { + ritual.effect.onRitualBroken(ritualStone, method); + } + } + } + + 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; + } + + public static String getPreviousRitualKey(String key) + { + boolean hasSpotted = false; + String lastKey = keyList.get(keyList.size() - 1); + + for (String str : keyList) + { + if (str.equals(key)) + { + hasSpotted = true; + } + if (hasSpotted) + { + return lastKey; + } + lastKey = str; + } + + return lastKey; + } + + public static MRSRenderer getRendererForKey(String ritualID) + { + if (ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if (ritual != null) + { + return ritual.getRenderer(); + } + } + + return null; + } + + public static LocalRitualStorage getLocalStorage(String ritualID) + { + if (ritualMap.containsKey(ritualID)) + { + Rituals ritual = ritualMap.get(ritualID); + if (ritual != null) + { + RitualEffect eff = ritual.effect; + if(eff != null) + { + return eff.getNewLocalStorage(); + } + } + } + + return null; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java new file mode 100644 index 0000000..c9b6931 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java @@ -0,0 +1,126 @@ +package WayofTime.alchemicalWizardry.api.soulNetwork; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.MinecraftServer; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.mojang.authlib.GameProfile; + + +/** + * Temporary class to hash-out how to create a network not completely tied to the player. + */ +public class ComplexNetworkHandler +{ + public static String fileName = "config/BloodMagic/soulnetworkKeys"; + static HashMap keyMap = new HashMap(); + public static UUID getUUIDFromPlayer(EntityPlayer player) + { + return player.getPersistentID(); + } + + public static EntityPlayer getPlayerFromUUID(UUID uuid) + { + MinecraftServer server = MinecraftServer.getServer(); + GameProfile gameProfile; + gameProfile = server.func_152358_ax().func_152652_a(uuid); + String str = uuid.toString(); + //TODO ServerConfigurationManager d.createPlayerForUser + UUID.fromString(str); + return null; + } + + public static String getKeyForPlayer(EntityPlayer player) + { + return ""; + } + + public static UUID getUUIDForKey(String key) + { +// if (MinecraftServer.getServer() == null) +// { +// return null; +// } +// +// World world = MinecraftServer.getServer().worldServers[0]; +// UUIDKeyMap data = (UUIDKeyMap) world.loadItemData(UUIDKeyMap.class, key); +// +// if (data == null) +// { +// data = new UUIDKeyMap(key); +// world.setItemData(key, data); +// } + return null; + } + + public static String assignKeyToPlayer(EntityPlayer player) + { + return ""; + } + + public static void save() + { + keyMap.put(new UUID(0, 0), "test"); + + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + String json = gson.toJson(keyMap); + Writer writer; + try + { + writer = new FileWriter(fileName + ".json"); + writer.write(json); + writer.close(); + } catch (IOException e) + { + e.printStackTrace(); + } + } + + public static void load() + { + File save = new File(fileName + ".json"); + + if(save.canRead()) + { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + BufferedReader br; + + try + { + br = new BufferedReader(new FileReader(save)); + HashMap schema = gson.fromJson(br, keyMap.getClass()); + + keyMap = schema; + + if(keyMap != null) + { + for(Entry entry : keyMap.entrySet()) + { + System.out.println("" + entry.getValue() + " gave: "+ entry.getKey()); + } + } + } catch (FileNotFoundException e) + { + e.printStackTrace(); + } + } + + else + { + keyMap = null; + } + } +} 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..91bcdaf --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/LifeEssenceNetwork.java @@ -0,0 +1,30 @@ +package WayofTime.alchemicalWizardry.api.soulNetwork; + +import net.minecraft.nbt.NBTTagCompound; + +public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData +{ + public int currentEssence; + public int maxOrb; + + public LifeEssenceNetwork(String par1Str) + { + super(par1Str); + currentEssence = 0; + maxOrb = 0; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + currentEssence = nbttagcompound.getInteger("currentEssence"); + maxOrb = nbttagcompound.getInteger("maxOrb"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + nbttagcompound.setInteger("currentEssence", currentEssence); + nbttagcompound.setInteger("maxOrb", maxOrb); + } +} 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..883c521 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java @@ -0,0 +1,458 @@ +package WayofTime.alchemicalWizardry.api.soulNetwork; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import WayofTime.alchemicalWizardry.api.event.AddToNetworkEvent; +import WayofTime.alchemicalWizardry.api.event.ItemBindEvent; +import WayofTime.alchemicalWizardry.api.event.ItemDrainInContainerEvent; +import WayofTime.alchemicalWizardry.api.event.ItemDrainNetworkEvent; + +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.Event.Result; + +public class SoulNetworkHandler +{ + public static UUID getUUIDFromPlayer(EntityPlayer player) + { + return player.getPersistentID(); + } + + public static EntityPlayer getPlayerFromUUID(UUID uuid) + { + MinecraftServer server = MinecraftServer.getServer(); + GameProfile gameProfile; + gameProfile = server.func_152358_ax().func_152652_a(uuid); + return null; + } + + public static boolean syphonFromNetworkWhileInContainer(ItemStack ist, int damageToBeDone) + { + String ownerName = ""; + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) + { + ownerName = ist.getTagCompound().getString("ownerName"); + } + + ItemDrainInContainerEvent event = new ItemDrainInContainerEvent(ist, ownerName, damageToBeDone); + + if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Result.DENY) + { + return false; + } + + return syphonFromNetwork(event.ownerNetwork, event.drainAmount) >= damageToBeDone; + } + + public static int getCurrentMaxOrb(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.maxOrb; + } + + public static void setMaxOrbToMax(String ownerName, int maxOrb) + { + 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.maxOrb = Math.max(maxOrb, data.maxOrb); + data.markDirty(); + } + + public static int getMaximumForOrbTier(int maxOrb) + { + switch(maxOrb) + { + case 1: + return 5000; + case 2: + return 25000; + case 3: + return 150000; + case 4: + return 1000000; + case 5: + return 10000000; + case 6: + return 30000000; + default: + return 1; + } + } + + public static int syphonFromNetwork(ItemStack ist, int damageToBeDone) + { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) + { + String ownerName = ist.getTagCompound().getString("ownerName"); + + return syphonFromNetwork(ownerName, damageToBeDone); + } + return 0; + } + + public static int syphonFromNetwork(String ownerName, int damageToBeDone) + { + 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 the action should be executed and false if it should not. Always returns false if client-sided. + */ + public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer player, int drain) + { + if (player.worldObj.isRemote) + { + return false; + } + + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) + { + String ownerName = ist.getTagCompound().getString("ownerName"); + + ItemDrainNetworkEvent event = new ItemDrainNetworkEvent(player, ownerName, ist, drain); + + if(MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + int drainAmount = syphonFromNetwork(event.ownerNetwork, event.drainAmount); + if(drainAmount == 0 || event.shouldDamage) + { + hurtPlayer(player, event.damageAmount); + } + + return (event.getResult() != Event.Result.DENY); //The event has been told to prevent the action but allow all repercussions of using the item. + } + + int amount = SoulNetworkHandler.syphonFromNetwork(ist, drain); + + hurtPlayer(player, drain - amount); + + return true; + } + + public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer player, int damageToBeDone) + { + if (player.worldObj.isRemote) + { + return false; + } + + World world = player.worldObj; + if (world != null) + { + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; + + world.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + } + + int amount = SoulNetworkHandler.syphonFromNetwork(ownerName, 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"); + + return canSyphonFromOnlyNetwork(ownerName, damageToBeDone); + } + + return false; + } + + public static boolean canSyphonFromOnlyNetwork(String ownerName, int damageToBeDone) + { + 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; + } + + 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) + { + AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum); + + if(MinecraftForge.EVENT_BUS.post(event)) + { + return 0; + } + + if (MinecraftServer.getServer() == null) + { + return 0; + } + + World world = MinecraftServer.getServer().worldServers[0]; + LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, event.ownerNetwork); + + if (data == null) + { + data = new LifeEssenceNetwork(event.ownerNetwork); + world.setItemData(event.ownerNetwork, data); + } + + int currEss = data.currentEssence; + + if (currEss >= event.maximum) + { + return 0; + } + + int newEss = Math.min(event.maximum, currEss + event.addedAmount); + if(event.getResult() != Event.Result.DENY) + { + 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 hurtPlayer(EntityPlayer user, float damage) + { + if (!user.capabilities.isCreativeMode) + { + user.setHealth((user.getHealth() - damage)); + + if (user.getHealth() <= 0.0005f) + { + user.onDeath(DamageSource.generic); + } + } + } + + public static boolean checkAndSetItemOwner(ItemStack item, EntityPlayer player) + { + if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").equals("")) return true; + + ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item); + + if(!MinecraftForge.EVENT_BUS.post(event)) + { + if (!item.hasTagCompound()) + { + item.setTagCompound(new NBTTagCompound()); + } + item.getTagCompound().setString("ownerName", event.key); + return true; + } + return false; + } + + public static void checkAndSetItemOwner(ItemStack item, String ownerName) + { + if (item.getTagCompound() == null) + { + item.setTagCompound(new NBTTagCompound()); + } + + if (item.getTagCompound().getString("ownerName").equals("")) + { + item.getTagCompound().setString("ownerName", ownerName); + } + } + + public static String getUsername(EntityPlayer player) + { + return player.getDisplayName(); + } + + public static EntityPlayer getPlayerForUsername(String str) + { + if (MinecraftServer.getServer() == null) + { + return null; + } + return MinecraftServer.getServer().getConfigurationManager().func_152612_a(str); + } + + public static void causeNauseaToPlayer(ItemStack stack) + { + if (stack.getTagCompound() != null && !(stack.getTagCompound().getString("ownerName").equals(""))) + { + String ownerName = stack.getTagCompound().getString("ownerName"); + + SoulNetworkHandler.causeNauseaToPlayer(ownerName); + } + } + + public static void causeNauseaToPlayer(String ownerName) + { + EntityPlayer entityOwner = SoulNetworkHandler.getPlayerForUsername(ownerName); + + if (entityOwner == null) + { + return; + } + + entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); + } + + public static String getOwnerName(ItemStack item) + { + if (item.getTagCompound() == null) + { + item.setTagCompound(new NBTTagCompound()); + } + + return item.getTagCompound().getString("ownerName"); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java new file mode 100644 index 0000000..bab2963 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java @@ -0,0 +1,325 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; +import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry; +import cpw.mods.fml.common.registry.GameRegistry; + +public class APISpellHelper +{ + /** + * Thanks Kihira! <3 + * @param player + * @return persistent data tag + */ + private static NBTTagCompound getPersistentDataTag(EntityPlayer player) + { + NBTTagCompound forgeData = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + NBTTagCompound beaconData = forgeData.getCompoundTag("BloodMagic"); + + //Creates/sets the tags if they don't exist + if (!forgeData.hasKey("BloodMagic")) forgeData.setTag("BloodMagic", beaconData); + if (!player.getEntityData().hasKey(EntityPlayer.PERSISTED_NBT_TAG)) player.getEntityData().setTag(EntityPlayer.PERSISTED_NBT_TAG, forgeData); + + return beaconData; + } + + public static int getPlayerLPTag(EntityPlayer player) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + if(data.hasKey("BM:StoredLP")) + { + return data.getInteger("BM:StoredLP"); + } + + return 0; + } + + public static void setPlayerLPTag(EntityPlayer player, int amount) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + data.setInteger("BM:StoredLP", amount); + } + + public static int getPlayerMaxLPTag(EntityPlayer player) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + if(data.hasKey("BM:MaxStoredLP")) + { + return data.getInteger("BM:MaxStoredLP"); + } + + return 0; + } + + public static void setPlayerMaxLPTag(EntityPlayer player, int amount) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + data.setInteger("BM:MaxStoredLP", amount); + } + + public static float getPlayerCurrentReagentAmount(EntityPlayer player) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + if(data.hasKey("BM:StoredReagentAmount")) + { + return data.getFloat("BM:StoredReagentAmount"); + } + + return 0; + } + + public static void setPlayerCurrentReagentAmount(EntityPlayer player, float amount) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + data.setFloat("BM:StoredReagentAmount", amount); + } + + public static float getPlayerMaxReagentAmount(EntityPlayer player) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + if(data.hasKey("BM:MaxReagentAmount")) + { + return data.getFloat("BM:MaxReagentAmount"); + } + + return 0; + } + + public static void setPlayerMaxReagentAmount(EntityPlayer player, float amount) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + data.setFloat("BM:MaxReagentAmount", amount); + } + + public static Reagent getPlayerReagentType(EntityPlayer player) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + if(data.hasKey("BM:ReagentType")) + { + return ReagentRegistry.getReagentForKey(data.getString("BM:ReagentType")); + } + + return null; + } + + public static void setPlayerReagentType(EntityPlayer player, String str) + { + NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); + data.setString("BM:ReagentType", str); + } + + public static void setPlayerReagentType(EntityPlayer player, Reagent reagent) + { + setPlayerReagentType(player, ReagentRegistry.getKeyForReagent(reagent)); + } + + public static float getCurrentAdditionalHP(EntityPlayer player) + { + NBTTagCompound data = player.getEntityData(); + if(data.hasKey("BM:CurrentAddedHP")) + { + return data.getFloat("BM:CurrentAddedHP"); + } + + return 0; + } + + public static void setCurrentAdditionalHP(EntityPlayer player, float amount) + { + NBTTagCompound data = player.getEntityData(); + data.setFloat("BM:CurrentAddedHP", amount); + } + + public static float getCurrentAdditionalMaxHP(EntityPlayer player) + { + NBTTagCompound data = player.getEntityData(); + if(data.hasKey("BM:MaxAddedHP")) + { + return data.getFloat("BM:MaxAddedHP"); + } + + return 0; + } + + public static void setCurrentAdditionalMaxHP(EntityPlayer player, float maxHP) + { + NBTTagCompound data = player.getEntityData(); + data.setFloat("BM:MaxAddedHP", maxHP); + } + + public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) + { + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f; + if (!world.isRemote && player instanceof EntityPlayer) + d1 += 1.62D; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; + Vec3 vec3 = APISpellHelper.createVec3(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + if (player instanceof EntityPlayerMP) + { +// d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); + } + Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); + return world.func_147447_a(vec3, vec31, par3, !par3, par3); + } + + public static Vec3 createVec3(double x, double y, double z) + { + return Vec3.createVectorHelper(x, y, z); + } + + public static List getItemsFromBlock(World world, Block block, int x, int y, int z, int meta, boolean silkTouch, int fortune) + { + boolean canSilk = block.canSilkHarvest(world, null, x, y, z, meta); + + if (canSilk && silkTouch) + { + ArrayList items = new ArrayList(); + ItemStack item = new ItemStack(block, 1, meta); + + items.add(item); + + return items; + } else + { + return block.getDrops(world, x, y, z, meta, fortune); + } + } + + public static void spawnItemListInWorld(List items, World world, float x, float y, float z) + { + for (ItemStack stack : items) + { + EntityItem itemEntity = new EntityItem(world, x, y, z, stack); + itemEntity.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(itemEntity); + } + } + + public static String getNumeralForInt(int num) + { + switch (num) + { + case 1: + return "I"; + case 2: + return "II"; + case 3: + return "III"; + case 4: + return "IV"; + case 5: + return "V"; + case 6: + return "VI"; + case 7: + return "VII"; + case 8: + return "VIII"; + case 9: + return "IX"; + case 10: + return "X"; + default: + return ""; + } + } + + public static Block getBlockForString(String str) + { + String[] parts = str.split(":"); + String modId = parts[0]; + String name = parts[1]; + return GameRegistry.findBlock(modId, name); + } + + public static Item getItemForString(String str) + { + String[] parts = str.split(":"); + String modId = parts[0]; + String name = parts[1]; + return GameRegistry.findItem(modId, name); + } + + public static ItemStack getItemStackForString(String str) + { + String[] parts = str.split(":"); + int meta = 0; + if(parts.length >= 3) + { + meta = Integer.decode(parts[2]); + }else if(parts.length < 2) + { + return null; + } + String modId = parts[0]; + String name = parts[1]; + + String itemString = modId + ":" + name; + Item item = APISpellHelper.getItemForString(itemString); + if(item != null) + { + return new ItemStack(item, 1, meta); + } + + Block block = APISpellHelper.getBlockForString(itemString); + if(block != null) + { + return new ItemStack(block, 1, meta); + } + + return null; + } + + public static IRecipe getRecipeForItemStack(ItemStack reqStack) //Does not match NBT. Durrr! -smack- + { + if(reqStack == null) + { + return null; //Why are you even doing this to yourself!? You know this can't be healthy! + } + List craftingList = CraftingManager.getInstance().getRecipeList(); + for(Object posRecipe : craftingList) + { + if(posRecipe instanceof IRecipe) + { + ItemStack outputStack = ((IRecipe) posRecipe).getRecipeOutput(); + if(outputStack != null) + { + if(outputStack.getItem() == reqStack.getItem() && (outputStack.getItem().getHasSubtypes() ? outputStack.getItemDamage() == reqStack.getItemDamage() : true)) + { + return (IRecipe)posRecipe; + } + } + } + } + + return null; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellEffect.java new file mode 100644 index 0000000..26bcfc2 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellEffect.java @@ -0,0 +1,92 @@ +package WayofTime.alchemicalWizardry.api.spell; + + +public abstract class ComplexSpellEffect +{ + public final ComplexSpellType type; + public final ComplexSpellModifier modifier; + + protected int powerEnhancement; + protected int costEnhancement; + protected int potencyEnhancement; + + public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier) + { + this.type = type; + this.modifier = modifier; + } + + public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier, int power, int cost, int potency) + { + this(type, modifier); + + this.powerEnhancement = power; + this.costEnhancement = cost; + this.potencyEnhancement = potency; + } + + public abstract void modifyParadigm(SpellParadigm parad); + + public ComplexSpellType getType() + { + return this.type; + } + + public ComplexSpellModifier getModifier() + { + return this.modifier; + } + + public abstract ComplexSpellEffect copy(int power, int cost, int potency); + + public abstract int getCostOfEffect(); + +// public NBTTagCompound getTag() +// { +// NBTTagCompound tag = new NBTTagCompound(); +// +// tag.setString("Class", this.getClass().getName()); +// tag.setInteger("modifier", modifierState); +// tag.setInteger("power", powerEnhancement); +// tag.setInteger("cost", costEnhancement); +// tag.setInteger("potency", potencyEnhancement); +// +// return tag; +// } +// +// public static SpellEffect getEffectFromTag(NBTTagCompound tag) +// { +// try +// { +// Class clazz = Class.forName(tag.getString("Class")); +// if (clazz != null) +// { +// try +// { +// Object obj = clazz.newInstance(); +// if (obj instanceof SpellEffect) +// { +// SpellEffect eff = (SpellEffect) obj; +// +// eff.modifierState = tag.getInteger("modifier"); +// eff.powerEnhancement = tag.getInteger("power"); +// eff.costEnhancement = tag.getInteger("cost"); +// eff.potencyEnhancement = tag.getInteger("potency"); +// +// return eff; +// } +// } catch (InstantiationException e) +// { +// e.printStackTrace(); +// } catch (IllegalAccessException e) +// { +// e.printStackTrace(); +// } +// } +// } catch (ClassNotFoundException e) +// { +// e.printStackTrace(); +// } +// return null; +// } +} \ No newline at end of file diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellModifier.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellModifier.java new file mode 100644 index 0000000..537a5e2 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellModifier.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public class ComplexSpellModifier +{ + public static ComplexSpellModifier DEFAULT = new ComplexSpellModifier(); + public static ComplexSpellModifier OFFENSIVE = new ComplexSpellModifier(); + public static ComplexSpellModifier DEFENSIVE = new ComplexSpellModifier(); + public static ComplexSpellModifier ENVIRONMENTAL = new ComplexSpellModifier(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellType.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellType.java new file mode 100644 index 0000000..1c308a8 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ComplexSpellType.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public class ComplexSpellType +{ + public static ComplexSpellType FIRE = new ComplexSpellType(); + public static ComplexSpellType ICE = new ComplexSpellType(); + public static ComplexSpellType EARTH = new ComplexSpellType(); + public static ComplexSpellType WIND = new ComplexSpellType(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java new file mode 100644 index 0000000..d6ed998 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java @@ -0,0 +1,654 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EntitySpellProjectile extends Entity implements IProjectile +{ + private int xTile = -1; + private int yTile = -1; + private int zTile = -1; + private int inTile = 0; + private int inData = 0; + private boolean inGround = false; + /** + * The owner of this arrow. + */ + public EntityPlayer shootingEntity; + private int ticksInAir = 0; + private int ricochetCounter = 0; + private boolean scheduledForDeath = false; + private boolean isSilkTouch = false; + + //Custom variables + private int maxRicochet = 0; + private float damage = 1; + public List impactList = new ArrayList(); + private boolean penetration = false; + public List updateEffectList = new ArrayList(); + public List spellEffectList = new LinkedList(); + private int blocksBroken = 0; + + public EntitySpellProjectile(World par1World) + { + super(par1World); + this.setSize(0.5F, 0.5F); + } + + public EntitySpellProjectile(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.setSize(0.5F, 0.5F); + this.setPosition(par2, par4, par6); + yOffset = 0.0F; + } + + public EntitySpellProjectile(World par1World, EntityPlayer par2EntityPlayer) + { + super(par1World); + shootingEntity = par2EntityPlayer; + float par3 = 0.8F; + this.setSize(0.1F, 0.1F); + this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch); + posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; + posY -= 0.2D; + posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; + this.setPosition(posX, posY, posZ); + yOffset = 0.0F; + motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); + motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); + motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI); + this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F); + + } + + @Override + protected void entityInit() + { + dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + } + + /** + * Similar to setArrowHeading, it's point the throwable entity to a x, y, z + * direction. + */ + @Override + public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) + { + float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5); + var1 /= var9; + var3 /= var9; + var5 /= var9; + var1 += rand.nextGaussian() * 0.007499999832361937D * var8; + var3 += rand.nextGaussian() * 0.007499999832361937D * var8; + var5 += rand.nextGaussian() * 0.007499999832361937D * var8; + var1 *= var7; + var3 *= var7; + var5 *= var7; + motionX = var1; + motionY = var3; + motionZ = var5; + float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5); + prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI); + } + + @Override + @SideOnly(Side.CLIENT) + /** + * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, + * posY, posZ, yaw, pitch + */ + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + + @Override + @SideOnly(Side.CLIENT) + /** + * Sets the velocity to the args. Args: x, y, z + */ + public void setVelocity(double par1, double par3, double par5) + { + motionX = par1; + motionY = par3; + motionZ = par5; + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch; + prevRotationYaw = rotationYaw; + this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); + } + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() + { + super.onUpdate(); + this.performUpdateEffects(); + if (ticksInAir > 600) + { + this.setDead(); + } + if (shootingEntity == null) + { + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1)); + Iterator i = players.iterator(); + double closestDistance = Double.MAX_VALUE; + EntityPlayer closestPlayer = null; + while (i.hasNext()) + { + EntityPlayer e = (EntityPlayer) i.next(); + double distance = e.getDistanceToEntity(this); + if (distance < closestDistance) + { + closestPlayer = e; + } + } + if (closestPlayer != null) + { + shootingEntity = closestPlayer; + } + } + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI); + } + Block var16 = worldObj.getBlock(xTile, yTile, zTile); + + if (var16 != null) + { + var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); + AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); + + if (var2 != null && var2.isVecInside(APISpellHelper.createVec3(posX, posY, posZ))) + { + inGround = true; + } + } + + if (inGround) + { + Block var18 = worldObj.getBlock(xTile, yTile, zTile); + int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile); + + if (var18.equals(Block.getBlockById(inTile)) && var19 == inData) + { + // this.groundImpact(); + // this.setDead(); + } + } else + { + ++ticksInAir; + + if (ticksInAir > 1 && ticksInAir < 3) + { + //worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0D, 0D, 0D); + for (int particles = 0; particles < 3; particles++) + { + this.doFiringParticles(); + } + } + + Vec3 var17 = APISpellHelper.createVec3(posX, posY, posZ); + Vec3 var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false); + var17 = APISpellHelper.createVec3(posX, posY, posZ); + var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); + + if (var4 != null) + { + var3 = APISpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); + } + + Entity var5 = null; + List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double var7 = 0.0D; + Iterator var9 = var6.iterator(); + float var11; + + while (var9.hasNext()) + { + Entity var10 = (Entity) var9.next(); + + if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5)) + { + var11 = 0.3F; + AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11); + MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); + + if (var13 != null) + { + double var14 = var17.distanceTo(var13.hitVec); + + if (var14 < var7 || var7 == 0.0D) + { + var5 = var10; + var7 = var14; + } + } + } + } + + if (var5 != null) + { + var4 = new MovingObjectPosition(var5); + } + + if (var4 != null) + { + this.onImpact(var4); + + if (scheduledForDeath) + { + this.setDead(); + } + } + + posX += motionX; + posY += motionY; + posZ += motionZ; + MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + this.setPosition(posX, posY, posZ); + //this.doBlockCollisions(); + } + } + + private void doFlightParticles() + { + if (ticksInAir % 3 == 0) + { + double gauss = gaussian(1.0F); + worldObj.spawnParticle("mobSpell", posX, posY, posZ, gauss, gauss, 0.0F); + } + } + + private void doFiringParticles() + { + worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D); + worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ)); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("xTile", (short) xTile); + par1NBTTagCompound.setShort("yTile", (short) yTile); + par1NBTTagCompound.setShort("zTile", (short) zTile); + par1NBTTagCompound.setByte("inTile", (byte) inTile); + par1NBTTagCompound.setByte("inData", (byte) inData); + par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0)); + + NBTTagList effectList = new NBTTagList(); + + for (SpellEffect eff : spellEffectList) + { + effectList.appendTag(eff.getTag()); + } + +// for (String str : this.effectList) +// { +// if (str != null) +// { +// NBTTagCompound tag = new NBTTagCompound(); +// +// tag.setString("Class", str); +// effectList.appendTag(tag); +// } +// } + + par1NBTTagCompound.setTag("Effects", effectList); + par1NBTTagCompound.setInteger("blocksBroken", blocksBroken); + par1NBTTagCompound.setBoolean("isSilkTouch", isSilkTouch); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + xTile = par1NBTTagCompound.getShort("xTile"); + yTile = par1NBTTagCompound.getShort("yTile"); + zTile = par1NBTTagCompound.getShort("zTile"); + inTile = par1NBTTagCompound.getByte("inTile") & 255; + inData = par1NBTTagCompound.getByte("inData") & 255; + inGround = par1NBTTagCompound.getByte("inGround") == 1; + blocksBroken = par1NBTTagCompound.getInteger("blocksBroken"); + isSilkTouch = par1NBTTagCompound.getBoolean("isSilkTouch"); + + NBTTagList tagList = par1NBTTagCompound.getTagList("Effects", Constants.NBT.TAG_COMPOUND); + + List spellEffectList = new LinkedList(); + for (int i = 0; i < tagList.tagCount(); i++) + { + NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); + + SpellEffect eff = SpellEffect.getEffectFromTag(tag); + if (eff != null) + { + spellEffectList.add(eff); + } + } + this.spellEffectList = spellEffectList; + + +// this.effectList = new LinkedList(); +// for (int i = 0; i < tagList.tagCount(); i++) +// { +// NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); +// +// this.effectList.add(tag.getString("Class")); +// } + + //SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForStringArray(effectList); + SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForEffectArray(spellEffectList); + parad.applyAllSpellEffects(); + parad.prepareProjectile(this); + } + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they + * walk on. used for spiders and wolves to prevent them from trampling crops + */ + @Override + protected boolean canTriggerWalking() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + /** + * Sets the amount of knockback the arrow applies when it hits a mob. + */ + public void setKnockbackStrength(int par1) + { + } + + /** + * If returns false, the item will not inflict any damage against entities. + */ + @Override + public boolean canAttackWithItem() + { + return false; + } + + /** + * Whether the arrow has a stream of critical hit particles flying behind + * it. + */ + public void setIsCritical(boolean par1) + { + byte var2 = dataWatcher.getWatchableObjectByte(16); + if (par1) + { + dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 | 1))); + } else + { + dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 & -2))); + } + } + + /** + * Whether the arrow has a stream of critical hit particles flying behind + * it. + */ + public boolean getIsCritical() + { + byte var1 = dataWatcher.getWatchableObjectByte(16); + return (var1 & 1) != 0; + } + + private void onImpact(MovingObjectPosition mop) + { + if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) + { + if (mop.entityHit == shootingEntity) return; + this.onImpact(mop.entityHit); + this.performEntityImpactEffects(mop.entityHit); + } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + if (!this.penetration) + { + this.groundImpact(mop.sideHit); + this.performTileImpactEffects(mop); + } + } + } + + private void onImpact(Entity mop) //TODO + { + if (mop == shootingEntity && ticksInAir > 3) + { + shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1); + this.setDead(); + } else + { + doDamage(this.damage, mop); + } + spawnHitParticles("exorcism", 8); + this.setDead(); + } + + + private void spawnHitParticles(String string, int i) + { + for (int particles = 0; particles < i; particles++) + { + worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), posGauss(1.0F), posGauss(1.0F), 0.0F); + } + } + + private void doDamage(float f, Entity mop) + { + mop.attackEntityFrom(this.getDamageSource(), f); + } + + private DamageSource getDamageSource() + { + return DamageSource.causePlayerDamage(shootingEntity); + } + + private void groundImpact(int sideHit) + { + this.ricochet(sideHit); + } + + private double smallGauss(double d) + { + return (worldObj.rand.nextFloat() - 0.5D) * d; + } + + private double posGauss(double d) + { + return rand.nextFloat() * 0.5D * d; + } + + private double gaussian(double d) + { + return d + d * ((rand.nextFloat() - 0.5D) / 4); + } + + private void ricochet(int sideHit) + { + switch (sideHit) + { + case 0: + case 1: + // topHit, bottomHit, reflect Y + motionY = motionY * -1; + break; + case 2: + case 3: + // westHit, eastHit, reflect Z + motionZ = motionZ * -1; + break; + case 4: + case 5: + // southHit, northHit, reflect X + motionX = motionX * -1; + break; + } + ricochetCounter++; + if (ricochetCounter > this.getRicochetMax()) + { + scheduledForDeath = true; + for (int particles = 0; particles < 4; particles++) + { + switch (sideHit) + { + case 0: + worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D)); + break; + case 1: + worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); + break; + case 2: + worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D)); + break; + case 3: + worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); + break; + case 4: + worldObj.spawnParticle("smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); + break; + case 5: + worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); + break; + } + } + } + } + + //Custom stuff + public int getRicochetMax() + { + return this.maxRicochet; + } + + public void setRicochetMax(int ricochet) + { + this.maxRicochet = ricochet; + } + + public void setImpactList(List list) + { + this.impactList = list; + } + + public void setUpdateEffectList(List list) + { + this.updateEffectList = list; + } + + private void performEntityImpactEffects(Entity mop) + { + if (impactList != null) + { + for (IProjectileImpactEffect impactEffect : impactList) + { + impactEffect.onEntityImpact(mop, this); + } + } + } + + private void performTileImpactEffects(MovingObjectPosition mop) + { + if (impactList != null) + { + for (IProjectileImpactEffect impactEffect : impactList) + { + impactEffect.onTileImpact(worldObj, mop); + } + } + } + + private void performUpdateEffects() + { + if (updateEffectList != null) + { + for (IProjectileUpdateEffect updateEffect : updateEffectList) + { + updateEffect.onUpdateEffect(this); + } + } + } + + public void setPenetration(boolean penetration) + { + this.penetration = penetration; + } + + public float getDamage() + { + return this.damage; + } + + public void setDamage(float damage) + { + this.damage = damage; + } + + public void setSpellEffectList(List list) + { + this.spellEffectList = list; + } + + public int getBlocksBroken() + { + return this.blocksBroken; + } + + public void setBlocksBroken(int blocksBroken) + { + this.blocksBroken = blocksBroken; + } + + public boolean getIsSilkTouch() + { + return this.isSilkTouch; + } + + public void setIsSilkTouch(boolean bool) + { + this.isSilkTouch = bool; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ExtrapolatedMeleeEntityEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ExtrapolatedMeleeEntityEffect.java new file mode 100644 index 0000000..0392937 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ExtrapolatedMeleeEntityEffect.java @@ -0,0 +1,72 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import java.util.List; + +public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntityEffect +{ + protected float range; + protected float radius; + protected int powerUpgrades; + protected int potencyUpgrades; + protected int costUpgrades; + protected int maxHit; + + public ExtrapolatedMeleeEntityEffect(int power, int potency, int cost) + { + this.powerUpgrades = power; + this.potencyUpgrades = potency; + this.costUpgrades = cost; + this.range = 0; + this.radius = 0; + this.maxHit = 1; + } + + @Override + public void onEntityImpact(World world, EntityPlayer entityPlayer) + { + Vec3 lookVec = entityPlayer.getLook(range); + double x = entityPlayer.posX + lookVec.xCoord; + double y = entityPlayer.posY + entityPlayer.getEyeHeight() + lookVec.yCoord; + double z = entityPlayer.posZ + lookVec.zCoord; + + List entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x - 0.5f, y - 0.5f, z - 0.5f, x + 0.5f, y + 0.5f, z + 0.5f).expand(radius, radius, radius)); + int hit = 0; + + if (entities != null) + { + for (Entity entity : entities) + { + if (hit < maxHit && !entity.equals(entityPlayer)) + { + if (this.entityEffect(world, entity, entityPlayer)) + { + hit++; + } + } + } + } + } + + protected abstract boolean entityEffect(World world, Entity entity, EntityPlayer player); + + public void setRange(float range) + { + this.range = range; + } + + public void setRadius(float radius) + { + this.radius = radius; + } + + public void setMaxNumberHit(int maxHit) + { + this.maxHit = maxHit; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IDigAreaEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IDigAreaEffect.java new file mode 100644 index 0000000..2355ed7 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IDigAreaEffect.java @@ -0,0 +1,12 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public interface IDigAreaEffect +{ + public abstract int digSurroundingArea(ItemStack container, World world, EntityPlayer player, MovingObjectPosition blockPos, String usedToolClass, float blockHardness, int harvestLvl, ItemSpellMultiTool itemTool); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IItemManipulator.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IItemManipulator.java new file mode 100644 index 0000000..eb9b766 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IItemManipulator.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +public interface IItemManipulator +{ + public List handleItemsOnBlockBroken(ItemStack toolStack, List itemList); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ILeftClickEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ILeftClickEffect.java new file mode 100644 index 0000000..65f53f8 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ILeftClickEffect.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +public interface ILeftClickEffect +{ + public abstract int onLeftClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellEntityEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellEntityEffect.java new file mode 100644 index 0000000..6b5d7ef --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellEntityEffect.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public interface IMeleeSpellEntityEffect +{ + public void onEntityImpact(World world, EntityPlayer entityPlayer); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellWorldEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellWorldEffect.java new file mode 100644 index 0000000..b0560cf --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IMeleeSpellWorldEffect.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public interface IMeleeSpellWorldEffect +{ + public void onWorldEffect(World world, EntityPlayer entityPlayer); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBanishTool.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBanishTool.java new file mode 100644 index 0000000..4e12fdd --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBanishTool.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IOnBanishTool +{ + public abstract int onBanishTool(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBreakBlock.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBreakBlock.java new file mode 100644 index 0000000..12f844c --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnBreakBlock.java @@ -0,0 +1,12 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public interface IOnBreakBlock +{ + public abstract int onBlockBroken(ItemStack container, World world, EntityPlayer player, Block block, int meta, int x, int y, int z, ForgeDirection sideBroken); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnSummonTool.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnSummonTool.java new file mode 100644 index 0000000..6a5ea4d --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IOnSummonTool.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IOnSummonTool +{ + public abstract int onSummonTool(ItemStack toolStack, World world, Entity entity); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileImpactEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileImpactEffect.java new file mode 100644 index 0000000..c534823 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileImpactEffect.java @@ -0,0 +1,12 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public interface IProjectileImpactEffect +{ + public void onEntityImpact(Entity mop, Entity projectile); + + public void onTileImpact(World world, MovingObjectPosition mop); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileUpdateEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileUpdateEffect.java new file mode 100644 index 0000000..e973538 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IProjectileUpdateEffect.java @@ -0,0 +1,8 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; + +public interface IProjectileUpdateEffect +{ + public void onUpdateEffect(Entity projectile); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IRightClickEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IRightClickEffect.java new file mode 100644 index 0000000..dd9f7d2 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IRightClickEffect.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public interface IRightClickEffect +{ + //public abstract int onRightClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder); + + public abstract int onRightClickBlock(ItemStack stack, EntityLivingBase weilder, World world, MovingObjectPosition mop); + + public abstract int onRightClickAir(ItemStack stack, EntityLivingBase weilder); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ISelfSpellEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ISelfSpellEffect.java new file mode 100644 index 0000000..c49edaf --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ISelfSpellEffect.java @@ -0,0 +1,9 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public interface ISelfSpellEffect +{ + public void onSelfUse(World world, EntityPlayer player); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ISpecialDamageEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ISpecialDamageEffect.java new file mode 100644 index 0000000..323ccf3 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ISpecialDamageEffect.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; + +public interface ISpecialDamageEffect +{ + public float getDamageForEntity(Entity entity); + + public String getKey(); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java new file mode 100644 index 0000000..c3bacfc --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IToolUpdateEffect +{ + public abstract int onUpdate(ItemStack toolStack, World world, Entity par3Entity, int invSlot, boolean inHand); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellCenteredWorldEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellCenteredWorldEffect.java new file mode 100644 index 0000000..68ec013 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellCenteredWorldEffect.java @@ -0,0 +1,33 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public abstract class MeleeSpellCenteredWorldEffect extends MeleeSpellWorldEffect +{ + protected float range; + + public MeleeSpellCenteredWorldEffect(int power, int potency, int cost) + { + super(power, potency, cost); + } + + @Override + public void onWorldEffect(World world, EntityPlayer entityPlayer) + { + Vec3 lookVec = entityPlayer.getLook(range).normalize(); + int x = (int) (entityPlayer.posX + lookVec.xCoord * range); + int y = (int) (entityPlayer.posY + entityPlayer.getEyeHeight() + lookVec.yCoord * range); + int z = (int) (entityPlayer.posZ + lookVec.zCoord * range); + + this.onCenteredWorldEffect(entityPlayer, world, x, y, z); + } + + public void setRange(float range) + { + this.range = range; + } + + public abstract void onCenteredWorldEffect(EntityPlayer player, World world, int posX, int posY, int posZ); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellWorldEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellWorldEffect.java new file mode 100644 index 0000000..844b540 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/MeleeSpellWorldEffect.java @@ -0,0 +1,21 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public abstract class MeleeSpellWorldEffect implements IMeleeSpellWorldEffect +{ + protected int powerUpgrades; + protected int potencyUpgrades; + protected int costUpgrades; + + public MeleeSpellWorldEffect(int power, int potency, int cost) + { + this.powerUpgrades = power; + this.potencyUpgrades = potency; + this.costUpgrades = cost; + } + + @Override + public abstract void onWorldEffect(World world, EntityPlayer entityPlayer); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileImpactEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileImpactEffect.java new file mode 100644 index 0000000..22ef5db --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileImpactEffect.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public abstract class ProjectileImpactEffect implements IProjectileImpactEffect +{ + protected int powerUpgrades; + protected int potencyUpgrades; + protected int costUpgrades; + + public ProjectileImpactEffect(int power, int potency, int cost) + { + this.powerUpgrades = power; + this.potencyUpgrades = potency; + this.costUpgrades = cost; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileUpdateEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileUpdateEffect.java new file mode 100644 index 0000000..500e7cf --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/ProjectileUpdateEffect.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public abstract class ProjectileUpdateEffect implements IProjectileUpdateEffect +{ + protected int powerUpgrades; + protected int potencyUpgrades; + protected int costUpgrades; + + public ProjectileUpdateEffect(int power, int potency, int cost) + { + this.powerUpgrades = power; + this.potencyUpgrades = potency; + this.costUpgrades = cost; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SelfSpellEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SelfSpellEffect.java new file mode 100644 index 0000000..5e9e356 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SelfSpellEffect.java @@ -0,0 +1,15 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public abstract class SelfSpellEffect implements ISelfSpellEffect +{ + protected int powerUpgrades; + protected int potencyUpgrades; + protected int costUpgrades; + + public SelfSpellEffect(int power, int potency, int cost) + { + this.powerUpgrades = power; + this.potencyUpgrades = potency; + this.costUpgrades = cost; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java new file mode 100644 index 0000000..1ae52ba --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java @@ -0,0 +1,500 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import net.minecraft.nbt.NBTTagCompound; + +/** + * New wrapper class to enclose the ComplexSpellEffect + */ +public class SpellEffect +{ + public ComplexSpellType type; + public ComplexSpellModifier modifier; + + protected int powerEnhancement; + protected int costEnhancement; + protected int potencyEnhancement; + + public SpellEffect() + { + this(ComplexSpellType.FIRE); + } + + public SpellEffect(ComplexSpellType type) + { + this(type, ComplexSpellModifier.DEFAULT); + } + + public SpellEffect(ComplexSpellType type, ComplexSpellModifier modifier) + { + this.type = type; + this.modifier = modifier; + + this.powerEnhancement = 0; + this.potencyEnhancement = 0; + this.costEnhancement = 0; + } + + public void enhanceEffect(SpellEnhancement enh) + { + if (enh != null) + { + switch (enh.getState()) + { + case SpellEnhancement.POWER: + this.powerEnhancement++; + break; + case SpellEnhancement.EFFICIENCY: + this.costEnhancement++; + break; + case SpellEnhancement.POTENCY: + this.potencyEnhancement++; + break; + } + } + } + + public void modifyEffect(ComplexSpellModifier mod) + { + if(mod != null) + { + this.modifier = mod; + } + } + + public void modifyParadigm(SpellParadigm parad) //When modifying the paradigm it will instead get the class name and ask the registry + { + if(parad == null) + { + return; + } + + Class paraClass = parad.getClass(); + + ComplexSpellEffect effect = SpellEffectRegistry.getSpellEffect(paraClass, type, modifier, powerEnhancement, potencyEnhancement, costEnhancement); + + if(effect != null) + { + effect.modifyParadigm(parad); + } + } + + public int getCostOfEffect(SpellParadigm parad) + { + if(parad == null) + { + return 0; + } + + Class paraClass = parad.getClass(); + + ComplexSpellEffect effect = SpellEffectRegistry.getSpellEffect(paraClass, type, modifier, powerEnhancement, potencyEnhancement, costEnhancement); + + if(effect == null) + { + return 0; + } + + return effect.getCostOfEffect(); + } + + public NBTTagCompound getTag() + { + NBTTagCompound tag = new NBTTagCompound(); + + tag.setString("Class", this.getClass().getName()); + tag.setString("type", SpellEffectRegistry.getKeyForType(type)); + tag.setString("modifier", SpellEffectRegistry.getKeyForModifier(modifier)); + tag.setInteger("power", powerEnhancement); + tag.setInteger("cost", costEnhancement); + tag.setInteger("potency", potencyEnhancement); + + return tag; + } + + public static SpellEffect getEffectFromTag(NBTTagCompound tag) + { + try + { + Class clazz = Class.forName(tag.getString("Class")); + if (clazz != null) + { + try + { + Object obj = clazz.newInstance(); + if (obj instanceof SpellEffect) + { + SpellEffect eff = (SpellEffect) obj; + + eff.type = SpellEffectRegistry.getTypeForKey(tag.getString("type")); + eff.modifier = SpellEffectRegistry.getModifierForKey(tag.getString("modifier")); + eff.powerEnhancement = tag.getInteger("power"); + eff.costEnhancement = tag.getInteger("cost"); + eff.potencyEnhancement = tag.getInteger("potency"); + + return eff; + } + } catch (InstantiationException e) + { + e.printStackTrace(); + } catch (IllegalAccessException e) + { + e.printStackTrace(); + } + } + } catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + return null; + } + + public int getPowerEnhancements() + { + return this.powerEnhancement; + } + + public int getPotencyEnhancements() + { + return this.potencyEnhancement; + } + + public int getCostEnhancements() + { + return this.costEnhancement; + } +} + +//package WayofTime.alchemicalWizardry.common.spell.complex.effect; +// +//import WayofTime.alchemicalWizardry.common.spell.complex.*; +//import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement; +//import net.minecraft.nbt.NBTTagCompound; +// +//public abstract class SpellEffect +//{ +// protected int modifierState; +// protected int powerEnhancement; +// protected int costEnhancement; +// protected int potencyEnhancement; +// +// public SpellEffect() +// { +// this.modifierState = SpellModifier.DEFAULT; +// this.powerEnhancement = 0; +// this.costEnhancement = 0; +// this.potencyEnhancement = 0; +// } +// +// public void enhanceEffect(SpellEnhancement enh) +// { +// if (enh != null) +// { +// switch (enh.getState()) +// { +// case SpellEnhancement.POWER: +// this.powerEnhancement++; +// break; +// case SpellEnhancement.EFFICIENCY: +// this.costEnhancement++; +// break; +// case SpellEnhancement.POTENCY: +// this.potencyEnhancement++; +// break; +// } +// } +// } +// +// public void modifyEffect(SpellModifier mod) +// { +// if (mod != null) +// modifierState = mod.getModifier(); +// } +// +// public void modifyParadigm(SpellParadigm parad) //When modifying the paradigm it will instead get the class name and ask the registry +// { +// if (parad instanceof SpellParadigmProjectile) +// { +// this.modifyProjectileParadigm((SpellParadigmProjectile) parad); +// } +// if (parad instanceof SpellParadigmSelf) +// { +// this.modifySelfParadigm((SpellParadigmSelf) parad); +// } +// if (parad instanceof SpellParadigmMelee) +// { +// this.modifyMeleeParadigm((SpellParadigmMelee) parad); +// } +// if (parad instanceof SpellParadigmTool) +// { +// this.modifyToolParadigm((SpellParadigmTool) parad); +// } +// } +// +// public void modifyProjectileParadigm(SpellParadigmProjectile parad) +// { +// switch (modifierState) +// { +// case SpellModifier.DEFAULT: +// this.defaultModificationProjectile(parad); +// break; +// case SpellModifier.OFFENSIVE: +// this.offensiveModificationProjectile(parad); +// break; +// case SpellModifier.DEFENSIVE: +// this.defensiveModificationProjectile(parad); +// break; +// case SpellModifier.ENVIRONMENTAL: +// this.environmentalModificationProjectile(parad); +// break; +// } +// } +// +// public abstract void defaultModificationProjectile(SpellParadigmProjectile parad); +// +// public abstract void offensiveModificationProjectile(SpellParadigmProjectile parad); +// +// public abstract void defensiveModificationProjectile(SpellParadigmProjectile parad); +// +// public abstract void environmentalModificationProjectile(SpellParadigmProjectile parad); +// +// public void modifySelfParadigm(SpellParadigmSelf parad) +// { +// switch (modifierState) +// { +// case SpellModifier.DEFAULT: +// this.defaultModificationSelf(parad); +// break; +// case SpellModifier.OFFENSIVE: +// this.offensiveModificationSelf(parad); +// break; +// case SpellModifier.DEFENSIVE: +// this.defensiveModificationSelf(parad); +// break; +// case SpellModifier.ENVIRONMENTAL: +// this.environmentalModificationSelf(parad); +// break; +// } +// } +// +// public abstract void defaultModificationSelf(SpellParadigmSelf parad); +// +// public abstract void offensiveModificationSelf(SpellParadigmSelf parad); +// +// public abstract void defensiveModificationSelf(SpellParadigmSelf parad); +// +// public abstract void environmentalModificationSelf(SpellParadigmSelf parad); +// +// public void modifyMeleeParadigm(SpellParadigmMelee parad) +// { +// switch (modifierState) +// { +// case SpellModifier.DEFAULT: +// this.defaultModificationMelee(parad); +// break; +// case SpellModifier.OFFENSIVE: +// this.offensiveModificationMelee(parad); +// break; +// case SpellModifier.DEFENSIVE: +// this.defensiveModificationMelee(parad); +// break; +// case SpellModifier.ENVIRONMENTAL: +// this.environmentalModificationMelee(parad); +// break; +// } +// } +// +// public abstract void defaultModificationMelee(SpellParadigmMelee parad); +// +// public abstract void offensiveModificationMelee(SpellParadigmMelee parad); +// +// public abstract void defensiveModificationMelee(SpellParadigmMelee parad); +// +// public abstract void environmentalModificationMelee(SpellParadigmMelee parad); +// +// public void modifyToolParadigm(SpellParadigmTool parad) +// { +// switch (modifierState) +// { +// case SpellModifier.DEFAULT: +// this.defaultModificationTool(parad); +// break; +// case SpellModifier.OFFENSIVE: +// this.offensiveModificationTool(parad); +// break; +// case SpellModifier.DEFENSIVE: +// this.defensiveModificationTool(parad); +// break; +// case SpellModifier.ENVIRONMENTAL: +// this.environmentalModificationTool(parad); +// break; +// } +// } +// +// public abstract void defaultModificationTool(SpellParadigmTool parad); +// +// public abstract void offensiveModificationTool(SpellParadigmTool parad); +// +// public abstract void defensiveModificationTool(SpellParadigmTool parad); +// +// public abstract void environmentalModificationTool(SpellParadigmTool parad); +// +// public int getCostForProjectile() +// { +// switch (this.modifierState) +// { +// case SpellModifier.DEFAULT: +// return this.getCostForDefaultProjectile(); +// case SpellModifier.OFFENSIVE: +// return this.getCostForOffenseProjectile(); +// case SpellModifier.DEFENSIVE: +// return this.getCostForDefenseProjectile(); +// case SpellModifier.ENVIRONMENTAL: +// return this.getCostForEnvironmentProjectile(); +// } +// return 0; +// } +// +// protected abstract int getCostForDefaultProjectile(); +// +// protected abstract int getCostForOffenseProjectile(); +// +// protected abstract int getCostForDefenseProjectile(); +// +// protected abstract int getCostForEnvironmentProjectile(); +// +// public int getCostForSelf() +// { +// switch (this.modifierState) +// { +// case SpellModifier.DEFAULT: +// return this.getCostForDefaultSelf(); +// case SpellModifier.OFFENSIVE: +// return this.getCostForOffenseSelf(); +// case SpellModifier.DEFENSIVE: +// return this.getCostForDefenseSelf(); +// case SpellModifier.ENVIRONMENTAL: +// return this.getCostForEnvironmentSelf(); +// } +// return 0; +// } +// +// protected abstract int getCostForDefaultSelf(); +// +// protected abstract int getCostForOffenseSelf(); +// +// protected abstract int getCostForDefenseSelf(); +// +// protected abstract int getCostForEnvironmentSelf(); +// +// public int getCostForMelee() +// { +// switch (this.modifierState) +// { +// case SpellModifier.DEFAULT: +// return this.getCostForDefaultMelee(); +// case SpellModifier.OFFENSIVE: +// return this.getCostForOffenseMelee(); +// case SpellModifier.DEFENSIVE: +// return this.getCostForDefenseMelee(); +// case SpellModifier.ENVIRONMENTAL: +// return this.getCostForEnvironmentMelee(); +// } +// return 0; +// } +// +// protected abstract int getCostForDefaultMelee(); +// +// protected abstract int getCostForOffenseMelee(); +// +// protected abstract int getCostForDefenseMelee(); +// +// protected abstract int getCostForEnvironmentMelee(); +// +// public int getCostForTool() +// { +// switch (this.modifierState) +// { +// case SpellModifier.DEFAULT: +// return this.getCostForDefaultTool(); +// case SpellModifier.OFFENSIVE: +// return this.getCostForOffenseTool(); +// case SpellModifier.DEFENSIVE: +// return this.getCostForDefenseTool(); +// case SpellModifier.ENVIRONMENTAL: +// return this.getCostForEnvironmentTool(); +// } +// return 0; +// } +// +// protected abstract int getCostForDefaultTool(); +// +// protected abstract int getCostForOffenseTool(); +// +// protected abstract int getCostForDefenseTool(); +// +// protected abstract int getCostForEnvironmentTool(); +// +// public int getPowerEnhancements() +// { +// return this.powerEnhancement; +// } +// +// public int getCostEnhancements() +// { +// return this.costEnhancement; +// } +// +// public int getPotencyEnhancements() +// { +// return this.potencyEnhancement; +// } +// +// public NBTTagCompound getTag() +// { +// NBTTagCompound tag = new NBTTagCompound(); +// +// tag.setString("Class", this.getClass().getName()); +// tag.setInteger("modifier", modifierState); +// tag.setInteger("power", powerEnhancement); +// tag.setInteger("cost", costEnhancement); +// tag.setInteger("potency", potencyEnhancement); +// +// return tag; +// } +// +// public static SpellEffect getEffectFromTag(NBTTagCompound tag) +// { +// try +// { +// Class clazz = Class.forName(tag.getString("Class")); +// if (clazz != null) +// { +// try +// { +// Object obj = clazz.newInstance(); +// if (obj instanceof SpellEffect) +// { +// SpellEffect eff = (SpellEffect) obj; +// +// eff.modifierState = tag.getInteger("modifier"); +// eff.powerEnhancement = tag.getInteger("power"); +// eff.costEnhancement = tag.getInteger("cost"); +// eff.potencyEnhancement = tag.getInteger("potency"); +// +// return eff; +// } +// } catch (InstantiationException e) +// { +// e.printStackTrace(); +// } catch (IllegalAccessException e) +// { +// e.printStackTrace(); +// } +// } +// } catch (ClassNotFoundException e) +// { +// e.printStackTrace(); +// } +// return null; +// } +//} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java new file mode 100644 index 0000000..f217b12 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java @@ -0,0 +1,157 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class SpellEffectRegistry +{ + public static Map, List> effectRegistry = new HashMap(); + public static Map typeRegistry = new HashMap(); + public static Map modifierRegistry = new HashMap(); + + public static void registerSpellEffect(Class paraClass, ComplexSpellEffect effect) + { + if(paraClass == null || effect == null) + { + return; + } + + if(effectRegistry.containsKey(paraClass)) + { + List effectList = effectRegistry.get(paraClass); + ComplexSpellType type = effect.getType(); + ComplexSpellModifier modifier = effect.getModifier(); + + if(type == null || modifier == null) + { + return; + } + + for(ComplexSpellEffect eff : effectList) + { + if(type.equals(eff.getType()) && modifier.equals(eff.getModifier())) + { + effectList.remove(eff); + effectList.add(effect); + return; + } + } + + effectList.add(effect); + }else + { + List effectList = new LinkedList(); + effectList.add(effect); + effectRegistry.put(paraClass, effectList); + } + } + + /** + * + * @param paraClass + * @param type + * @param mod + * @return A copy of the spell effect + */ + public static ComplexSpellEffect getSpellEffect(Class paraClass, ComplexSpellType type, ComplexSpellModifier mod) + { + return SpellEffectRegistry.getSpellEffect(paraClass, type, mod, 0, 0, 0); + } + + public static ComplexSpellEffect getSpellEffect(Class paraClass, ComplexSpellType type, ComplexSpellModifier mod, int power, int potency, int cost) + { + if(paraClass == null || type == null || mod == null) + { + return null; + } + + List list = effectRegistry.get(paraClass); + + if(list == null || list.isEmpty()) + { + return null; + } + + for(ComplexSpellEffect effect : list) + { + if(effect != null && type.equals(effect.type) && mod.equals(effect.modifier)) + { + return effect.copy(power, cost, potency); + } + } + + return null; + } + + public static void registerSpellType(String key, ComplexSpellType type) + { + typeRegistry.put(key, type); + } + + public static void registerSpellModifier(String key, ComplexSpellModifier modifier) + { + modifierRegistry.put(key, modifier); + } + + public static ComplexSpellType getTypeForKey(String key) + { + return typeRegistry.get(key); + } + + public static String getKeyForType(ComplexSpellType type) + { + if(type == null) + { + return ""; + } + + for(Entry entry : typeRegistry.entrySet()) + { + if(type.equals(entry.getValue())) + { + return entry.getKey(); + } + } + + return ""; + } + + public static ComplexSpellModifier getModifierForKey(String key) + { + return modifierRegistry.get(key); + } + + public static String getKeyForModifier(ComplexSpellModifier modifier) + { + if(modifier == null) + { + return ""; + } + + for(Entry entry : modifierRegistry.entrySet()) + { + if(modifier.equals(entry.getValue())) + { + return entry.getKey(); + } + } + + return ""; + } + + public static void initiateRegistry() + { + SpellEffectRegistry.registerSpellType("FIRE", ComplexSpellType.FIRE); + SpellEffectRegistry.registerSpellType("ICE", ComplexSpellType.ICE); + SpellEffectRegistry.registerSpellType("EARTH", ComplexSpellType.EARTH); + SpellEffectRegistry.registerSpellType("WIND", ComplexSpellType.WIND); + + SpellEffectRegistry.registerSpellModifier("DEFAULT", ComplexSpellModifier.DEFAULT); + SpellEffectRegistry.registerSpellModifier("OFFENSIVE", ComplexSpellModifier.OFFENSIVE); + SpellEffectRegistry.registerSpellModifier("DEFENSIVE", ComplexSpellModifier.DEFENSIVE); + SpellEffectRegistry.registerSpellModifier("ENVIRONMENTAL", ComplexSpellModifier.ENVIRONMENTAL); + } +} \ No newline at end of file diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java new file mode 100644 index 0000000..acbbdcc --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java @@ -0,0 +1,20 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public class SpellEnhancement +{ + public static final int POWER = 0; + public static final int EFFICIENCY = 1; + public static final int POTENCY = 2; + + private int state = this.POWER; + + protected SpellEnhancement(int state) + { + this.state = state; + } + + public int getState() + { + return this.state; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementCost.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementCost.java new file mode 100644 index 0000000..8078ce6 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementCost.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public class SpellEnhancementCost extends SpellEnhancement +{ + + public SpellEnhancementCost() + { + super(SpellEnhancement.EFFICIENCY); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPotency.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPotency.java new file mode 100644 index 0000000..a540f89 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPotency.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public class SpellEnhancementPotency extends SpellEnhancement +{ + public SpellEnhancementPotency() + { + super(SpellEnhancement.POTENCY); + } + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPower.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPower.java new file mode 100644 index 0000000..044ef10 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancementPower.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.spell; + +public class SpellEnhancementPower extends SpellEnhancement +{ + + public SpellEnhancementPower() + { + super(SpellEnhancement.POWER); + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java new file mode 100644 index 0000000..5423cb4 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java @@ -0,0 +1,131 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public abstract class SpellParadigm +{ + protected List bufferedEffectList = new LinkedList(); + + public void addBufferedEffect(SpellEffect effect) + { + if (effect != null) + { + this.bufferedEffectList.add(effect); + } + } + + public void modifyBufferedEffect(ComplexSpellModifier modifier) + { + SpellEffect effect = this.getBufferedEffect(); + if (effect != null) + { + effect.modifyEffect(modifier); + } + } + + public void applyEnhancement(SpellEnhancement enh) + { + if (enh != null) + { + if (bufferedEffectList.isEmpty()) + { + this.enhanceParadigm(enh); + } else + { + SpellEffect effect = this.getBufferedEffect(); + if (effect != null) + { + effect.enhanceEffect(enh); + } + } + } + + } + + public abstract void enhanceParadigm(SpellEnhancement enh); + + public abstract void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack); + + public void applySpellEffect(SpellEffect effect) + { + effect.modifyParadigm(this); + } + + public void applyAllSpellEffects() + { + for (SpellEffect effect : bufferedEffectList) + { + this.applySpellEffect(effect); + } + } + + public SpellEffect getBufferedEffect() + { + if (bufferedEffectList.isEmpty()) + { + return null; + } else + { + return bufferedEffectList.get(bufferedEffectList.size() - 1); + } + } + + public int getTotalCost() + { + int cost = 0; + if (this.bufferedEffectList != null && !this.bufferedEffectList.isEmpty()) + { + for(SpellEffect effect : bufferedEffectList) + { + cost += effect.getCostOfEffect(this); + } + + return (int) (cost * Math.sqrt(this.bufferedEffectList.size())); + } + + return getDefaultCost(); + } + + public abstract int getDefaultCost(); + + public int getBufferedEffectPower() + { + SpellEffect eff = this.getBufferedEffect(); + + if (eff != null) + { + return eff.getPowerEnhancements(); + } + + return 0; + } + + public int getBufferedEffectCost() + { + SpellEffect eff = this.getBufferedEffect(); + + if (eff != null) + { + return eff.getCostEnhancements(); + } + + return 0; + } + + public int getBufferedEffectPotency() + { + SpellEffect eff = this.getBufferedEffect(); + + if (eff != null) + { + return eff.getPotencyEnhancements(); + } + + return 0; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java new file mode 100644 index 0000000..629f7db --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java @@ -0,0 +1,70 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +public class SpellParadigmMelee extends SpellParadigm +{ + private List entityEffectList; + private List worldEffectList; + + public SpellParadigmMelee() + { + this.entityEffectList = new ArrayList(); + this.worldEffectList = new ArrayList(); + } + + @Override + public void enhanceParadigm(SpellEnhancement enh) + { + + } + + @Override + public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack) + { + int cost = this.getTotalCost(); + + if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost)) + { + return; + } + + for (IMeleeSpellEntityEffect effect : entityEffectList) + { + effect.onEntityImpact(world, entityPlayer); + } + + for (IMeleeSpellWorldEffect effect : worldEffectList) + { + effect.onWorldEffect(world, entityPlayer); + } + } + + public void addEntityEffect(IMeleeSpellEntityEffect eff) + { + if (eff != null) + { + this.entityEffectList.add(eff); + } + } + + public void addWorldEffect(IMeleeSpellWorldEffect eff) + { + if (eff != null) + { + this.worldEffectList.add(eff); + } + } + + @Override + public int getDefaultCost() + { + return 0; + } +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java new file mode 100644 index 0000000..8b6f6a3 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java @@ -0,0 +1,101 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +public class SpellParadigmProjectile extends SpellParadigm +{ + public DamageSource damageSource; + public float damage; + public int cost; + public List impactList; + public List updateEffectList; + public boolean penetration; + public int ricochetMax; + public boolean isSilkTouch; + + public SpellParadigmProjectile() + { + this.damageSource = DamageSource.generic; + this.damage = 1; + this.cost = 0; + this.impactList = new ArrayList(); + this.updateEffectList = new ArrayList(); + this.penetration = false; + this.ricochetMax = 0; + this.isSilkTouch = false; + } + + @Override + public void enhanceParadigm(SpellEnhancement enh) + { + + } + + @Override + public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack) + { + int cost = this.getTotalCost(); + + if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost)) + { + return; + } + + EntitySpellProjectile proj = new EntitySpellProjectile(world, entityPlayer); + this.prepareProjectile(proj); + world.spawnEntityInWorld(proj); + } + + public static SpellParadigmProjectile getParadigmForEffectArray(List effectList) + { + SpellParadigmProjectile parad = new SpellParadigmProjectile(); + + for (SpellEffect eff : effectList) + { + parad.addBufferedEffect(eff); + } + + return parad; + } + + public void prepareProjectile(EntitySpellProjectile proj) + { + proj.setDamage(damage); + proj.setImpactList(impactList); + proj.setUpdateEffectList(updateEffectList); + proj.setPenetration(penetration); + proj.setRicochetMax(ricochetMax); + proj.setIsSilkTouch(isSilkTouch); + proj.setSpellEffectList(bufferedEffectList); + } + + public void addImpactEffect(IProjectileImpactEffect eff) + { + if (eff != null) + { + this.impactList.add(eff); + } + } + + public void addUpdateEffect(IProjectileUpdateEffect eff) + { + if (eff != null) + { + this.updateEffectList.add(eff); + } + } + + @Override + public int getDefaultCost() + { + return 50; + } + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java new file mode 100644 index 0000000..89cffe0 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java @@ -0,0 +1,58 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +public class SpellParadigmSelf extends SpellParadigm +{ + public List selfSpellEffectList; + + public SpellParadigmSelf() + { + selfSpellEffectList = new ArrayList(); + } + + @Override + public void enhanceParadigm(SpellEnhancement enh) + { + + } + + @Override + public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack) + { + this.applyAllSpellEffects(); + + int cost = this.getTotalCost(); + + if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost)) + { + return; + } + + for (ISelfSpellEffect eff : selfSpellEffectList) + { + eff.onSelfUse(world, entityPlayer); + } + } + + public void addSelfSpellEffect(ISelfSpellEffect eff) + { + if (eff != null) + { + this.selfSpellEffectList.add(eff); + } + } + + @Override + public int getDefaultCost() + { + return 100; + } + +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java new file mode 100644 index 0000000..f6cc001 --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java @@ -0,0 +1,485 @@ +package WayofTime.alchemicalWizardry.api.spell; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +public class SpellParadigmTool extends SpellParadigm +{ + private List leftClickEffectList; + private List rightClickEffectList; + private List toolUpdateEffectList; + private List toolSummonEffectList; + private List toolBanishEffectList; + private List breakBlockEffectList; + private List itemManipulatorEffectList; + private List digAreaEffectList; + private List specialDamageEffectList; + + private float maxDamage; + private HashMap harvestLevel; + private HashMap digSpeed; + private HashMap maxDamageHash; + private HashMap critChanceHash; + private HashMap durationHash; + + private HashMap toolInfoString; + + private int fortuneLevel; + private boolean silkTouch; + + private int duration; + + public static Item customTool; + + public SpellParadigmTool() + { + this.leftClickEffectList = new LinkedList(); + this.rightClickEffectList = new LinkedList(); + this.toolUpdateEffectList = new LinkedList(); + this.toolSummonEffectList = new LinkedList(); + this.toolBanishEffectList = new LinkedList(); + this.breakBlockEffectList = new LinkedList(); + this.itemManipulatorEffectList = new LinkedList(); + this.digAreaEffectList = new LinkedList(); + this.specialDamageEffectList = new LinkedList(); + this.durationHash = new HashMap(); + + this.toolInfoString = new HashMap(); + this.critChanceHash = new HashMap(); + + this.maxDamage = 5; + + this.harvestLevel = new HashMap(); + this.harvestLevel.put("pickaxe", -1); + this.harvestLevel.put("shovel", -1); + this.harvestLevel.put("axe", -1); + + this.digSpeed = new HashMap(); + this.digSpeed.put("pickaxe", 1.0f); + this.digSpeed.put("shovel", 1.0f); + this.digSpeed.put("axe", 1.0f); + + this.maxDamageHash = new HashMap(); + this.maxDamageHash.put("default", 5.0f); + + this.fortuneLevel = 0; + this.silkTouch = false; + this.duration = 0; + this.durationHash.put("default", 2400); + } + + @Override + public void enhanceParadigm(SpellEnhancement enh) + { + + } + + @Override + public void castSpell(World world, EntityPlayer entityPlayer, ItemStack crystal) + { + if (entityPlayer.worldObj.isRemote) + { + return; + } + + int cost = this.getTotalCost(); + + if(!SoulNetworkHandler.syphonAndDamageFromNetwork(crystal, entityPlayer, cost)) + { + return; + } + + ItemStack toolStack = this.prepareTool(crystal, world); + + entityPlayer.setCurrentItemOrArmor(0, toolStack); + + this.onSummonTool(toolStack, world, entityPlayer); + } + + /** + * @param crystalStack + * @return stack containing the new multitool + */ + public ItemStack prepareTool(ItemStack crystalStack, World world) + { + ItemStack toolStack = new ItemStack(customTool, 1); + + ItemSpellMultiTool itemTool = (ItemSpellMultiTool) customTool; + + itemTool.setItemAttack(toolStack, this.composeMaxDamageFromHash()); + + Set> harvestLevelSet = this.harvestLevel.entrySet(); + + for (Entry testMap : harvestLevelSet) + { + String tool = testMap.getKey(); + int level = testMap.getValue(); + + itemTool.setHarvestLevel(toolStack, tool, level); + } + + Set> digSpeedSet = this.digSpeed.entrySet(); + + for (Entry testMap : digSpeedSet) + { + String tool = testMap.getKey(); + float speed = testMap.getValue(); + + itemTool.setDigSpeed(toolStack, tool, speed); + } + + itemTool.setFortuneLevel(toolStack, getFortuneLevel()); + itemTool.setSilkTouch(toolStack, this.getSilkTouch()); + + if (this.getSilkTouch()) + { + this.addToolString("SilkTouch", "Silk Touch" + " " + APISpellHelper.getNumeralForInt(1)); + } + + if (this.getFortuneLevel() > 0) + { + this.addToolString("Fortune", "Fortune" + " " + APISpellHelper.getNumeralForInt(this.getFortuneLevel())); + } + + itemTool.setCritChance(toolStack, this.getCritChance() / 100f); + + List toolStringList = new LinkedList(); + + for (String str : this.toolInfoString.values()) + { + toolStringList.add(str); + } + + itemTool.setToolListString(toolStack, toolStringList); + + for (Integer integ : this.durationHash.values()) + { + this.duration += integ; + } + + itemTool.setDuration(toolStack, world, this.duration); + itemTool.loadParadigmIntoStack(toolStack, this.bufferedEffectList); + + SoulNetworkHandler.checkAndSetItemOwner(toolStack, SoulNetworkHandler.getOwnerName(crystalStack)); + + itemTool.setContainedCrystal(toolStack, crystalStack); + + return toolStack; + } + + @Override + public int getDefaultCost() + { + return 100; + } + + public static SpellParadigmTool getParadigmForEffectArray(List effectList) + { + SpellParadigmTool parad = new SpellParadigmTool(); + + for (SpellEffect eff : effectList) + { + parad.addBufferedEffect(eff); + } + + parad.applyAllSpellEffects(); + + return parad; + } + + public void addLeftClickEffect(ILeftClickEffect eff) + { + if (eff != null) + { + this.leftClickEffectList.add(eff); + } + } + + public void addRightClickEffect(IRightClickEffect eff) + { + if (eff != null) + { + this.rightClickEffectList.add(eff); + } + } + + public void addUpdateEffect(IToolUpdateEffect eff) + { + if (eff != null) + { + this.toolUpdateEffectList.add(eff); + } + } + + public void addToolSummonEffect(IOnSummonTool eff) + { + if (eff != null) + { + this.toolSummonEffectList.add(eff); + } + } + + public void addToolBanishEffect(IOnBanishTool eff) + { + if (eff != null) + { + this.toolBanishEffectList.add(eff); + } + } + + public void addBlockBreakEffect(IOnBreakBlock eff) + { + if (eff != null) + { + this.breakBlockEffectList.add(eff); + } + } + + public void addItemManipulatorEffect(IItemManipulator eff) + { + if (eff != null) + { + this.itemManipulatorEffectList.add(eff); + } + } + + public void addDigAreaEffect(IDigAreaEffect eff) + { + if (eff != null) + { + this.digAreaEffectList.add(eff); + } + } + + public void addSpecialDamageEffect(ISpecialDamageEffect eff) + { + if (eff != null) + { + this.specialDamageEffectList.add(eff); + } + } + + public int onLeftClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder) + { + int total = 0; + for (ILeftClickEffect effect : this.leftClickEffectList) + { + total += effect.onLeftClickEntity(stack, attacked, weilder); + } + + return total; + } + + public int onRightClickBlock(ItemStack toolStack, EntityLivingBase weilder, World world, MovingObjectPosition mop) + { + int total = 0; + for (IRightClickEffect effect : this.rightClickEffectList) + { + total += effect.onRightClickBlock(toolStack, weilder, world, mop); + } + + return total; + } + + public int onRightClickAir(ItemStack toolStack, World world, EntityPlayer player) + { + int total = 0; + for (IRightClickEffect effect : this.rightClickEffectList) + { + total += effect.onRightClickAir(toolStack, player); + } + + return total; + } + + public int onUpdate(ItemStack toolStack, World world, Entity par3Entity, int invSlot, boolean inHand) + { + int total = 0; + for (IToolUpdateEffect effect : this.toolUpdateEffectList) + { + total += effect.onUpdate(toolStack, world, par3Entity, invSlot, inHand); + } + + return total; + } + + public int onSummonTool(ItemStack toolStack, World world, Entity entity) + { + int total = 0; + for (IOnSummonTool effect : this.toolSummonEffectList) + { + total += effect.onSummonTool(toolStack, world, entity); + } + + return total; + } + + public int onBanishTool(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand) + { + int total = 0; + for (IOnBanishTool effect : this.toolBanishEffectList) + { + total += effect.onBanishTool(toolStack, world, entity, invSlot, inHand); + } + + return total; + } + + public int onBreakBlock(ItemStack container, World world, EntityPlayer player, Block block, int meta, int x, int y, int z, ForgeDirection sideBroken) + { + int total = 0; + for (IOnBreakBlock effect : this.breakBlockEffectList) + { + total += effect.onBlockBroken(container, world, player, block, meta, x, y, z, sideBroken); + } + + return total; + } + + public List handleItemList(ItemStack toolStack, List items) + { + List heldList = items; + + for (IItemManipulator eff : this.itemManipulatorEffectList) + { + List newHeldList = eff.handleItemsOnBlockBroken(toolStack, heldList); + heldList = newHeldList; + } + + return heldList; + } + + public int digSurroundingArea(ItemStack container, World world, EntityPlayer player, MovingObjectPosition blockPos, String usedToolClass, float blockHardness, int harvestLvl, ItemSpellMultiTool itemTool) + { + int cost = 0; + + for (IDigAreaEffect effect : this.digAreaEffectList) + { + cost += effect.digSurroundingArea(container, world, player, blockPos, usedToolClass, blockHardness, harvestLvl, itemTool); + } + + return cost; + } + + public int getFortuneLevel() + { + return this.fortuneLevel; + } + + public void setFortuneLevel(int fortuneLevel) + { + this.fortuneLevel = fortuneLevel; + } + + public boolean getSilkTouch() + { + return this.silkTouch; + } + + public void setSilkTouch(boolean silkTouch) + { + this.silkTouch = silkTouch; + } + + public int getDuration() + { + return this.duration; + } + + public void setDuration(int duration) + { + this.duration = duration; + } + + public void setDigSpeed(String toolClass, float digSpeed) + { + this.digSpeed.put(toolClass, digSpeed); + } + + public void setHarvestLevel(String toolClass, int hlvl) + { + this.harvestLevel.put(toolClass, hlvl); + } + + public float composeMaxDamageFromHash() + { + float damage = 0.0f; + + for (float f : this.maxDamageHash.values()) + { + damage += f; + } + + return damage; + } + + public void addDamageToHash(String key, float dmg) + { + this.maxDamageHash.put(key, dmg); + } + + public void addToolString(String key, String str) + { + if (str != null && key != null) + { + this.toolInfoString.put(key, str); + } + } + + public void addCritChance(String key, float chance) + { + //Chance is in percentage chance i.e. chance = 1.0 means 1.0% + this.critChanceHash.put(key, chance); + } + + public void addDuration(String key, int dur) + { + this.durationHash.put(key, dur); + } + + public float getCritChance() + { + float chance = 0.0f; + + for (float fl : this.critChanceHash.values()) + { + chance += fl; + } + + return chance; + } + + public float getAddedDamageForEntity(Entity entity) + { + HashMap hash = new HashMap(); + + for (ISpecialDamageEffect effect : this.specialDamageEffectList) + { + hash.put(effect.getKey(), effect.getDamageForEntity(entity)); + } + + float addedDmg = 0.0f; + + for (float fl : hash.values()) + { + addedDmg += fl; + } + + return addedDmg; + } +} \ No newline at end of file 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..84c4d3a --- /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 String id; + + public SummoningHelper(String id) + { + this.id = id; + } + + public abstract EntityLivingBase getEntity(World worldObj); + + public String 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..18180d8 --- /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, String id) + { + for (SummoningRegistryComponent src : summoningList) + { + if (src.getSummoningHelperID().equals(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..72dbd83 --- /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 String 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/WayofTime/alchemicalWizardry/api/tile/ISpellParadigmTile.java b/src/api/java/WayofTime/alchemicalWizardry/api/tile/ISpellParadigmTile.java new file mode 100644 index 0000000..de9994b --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/tile/ISpellParadigmTile.java @@ -0,0 +1,10 @@ +package WayofTime.alchemicalWizardry.api.tile; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface ISpellParadigmTile extends ISpellTile +{ + public void castSpell(World world, EntityPlayer entity, ItemStack spellCasterStack); +} diff --git a/src/api/java/WayofTime/alchemicalWizardry/api/tile/ISpellTile.java b/src/api/java/WayofTime/alchemicalWizardry/api/tile/ISpellTile.java new file mode 100644 index 0000000..143a0ea --- /dev/null +++ b/src/api/java/WayofTime/alchemicalWizardry/api/tile/ISpellTile.java @@ -0,0 +1,11 @@ +package WayofTime.alchemicalWizardry.api.tile; + +import net.minecraftforge.common.util.ForgeDirection; +import WayofTime.alchemicalWizardry.api.spell.SpellParadigm; + +public interface ISpellTile +{ + public void modifySpellParadigm(SpellParadigm parad); + + public boolean canInputRecieveOutput(ForgeDirection output); +} diff --git a/src/main/java/fox/spiteful/forbidden/Config.java b/src/main/java/fox/spiteful/forbidden/Config.java index 8eb1827..43d9600 100644 --- a/src/main/java/fox/spiteful/forbidden/Config.java +++ b/src/main/java/fox/spiteful/forbidden/Config.java @@ -25,6 +25,8 @@ public class Config { public static int voidEnchID; public static int impactEnchID; + public static int bloodSealPotionID = 70; + public static int hellfireUpgradeID; public static int pandemoniumUpgradeID; @@ -46,6 +48,7 @@ public class Config { public static boolean crossMod = true; public static boolean crossWand = true; public static boolean botan = true; + public static boolean bloodMagic = true; public static boolean am2 = false; public static boolean tt = true; public static boolean tc = true; @@ -93,9 +96,12 @@ public class Config { if(gluttony < 0 || gluttony > 2) gluttony = 0; + bloodSealPotionID = conf.get("potions", "Blood Seal", bloodSealPotionID).getInt(bloodSealPotionID); + crossMod = conf.get("compatibility", "Cross-Mod Interaction", crossMod, "Disable to keep mods segregated.").getBoolean(true); crossWand = conf.get("compatibility", "Conversion Wands", crossWand, "Disable to remove all conversion wands.").getBoolean(true); botan = conf.get("compatibility", "Botania Interaction", botan).getBoolean(true); + bloodMagic = conf.get("compatibility", "Blood Magic Interaction", bloodMagic).getBoolean(true); am2 = conf.get("compatibility", "Ars Magica 2 Interaction", am2, "AM2 interaction is unsupported. Enable at your own risk.").getBoolean(false); tt = conf.get("compatibility", "Thaumic Tinkerer Interaction", tt).getBoolean(true); tc = conf.get("compatibility", "Tinkers Construct Interaction", tc).getBoolean(true); diff --git a/src/main/java/fox/spiteful/forbidden/FMEventHandler.java b/src/main/java/fox/spiteful/forbidden/FMEventHandler.java index b749a6b..c363783 100644 --- a/src/main/java/fox/spiteful/forbidden/FMEventHandler.java +++ b/src/main/java/fox/spiteful/forbidden/FMEventHandler.java @@ -2,13 +2,16 @@ package fox.spiteful.forbidden; import java.util.*; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import baubles.common.lib.PlayerHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import fox.spiteful.forbidden.blocks.ForbiddenBlocks; +import fox.spiteful.forbidden.compat.Compat; import fox.spiteful.forbidden.items.tools.ItemRidingCrop; import fox.spiteful.forbidden.items.baubles.ItemSubCollar; import fox.spiteful.forbidden.items.tools.ItemTaintPickaxe; +import fox.spiteful.forbidden.potions.DarkPotions; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -88,6 +91,20 @@ public class FMEventHandler { @SubscribeEvent public void onLivingDrops(LivingDropsEvent event) { + if (event.source.getDamageType().equals("player") && event.entityLiving instanceof ITaintedMob) + { + PotionEffect effect = event.entityLiving.getActivePotionEffect(Potion.weakness); + if (effect != null) + { + if (effect.getAmplifier() >= 2) { + double rand = Math.random(); + if (rand < 0.50d) { + addDrop(event, new ItemStack(ForbiddenItems.resource, 1, 3)); + } + } + } + } + if (Config.silverfishEmeralds && event.entityLiving instanceof EntitySilverfish) { if (event.entityLiving.worldObj.getBiomeGenForCoords((int) event.entityLiving.posX, (int) event.entityLiving.posZ).biomeID == BiomeGenBase.extremeHills.biomeID) { if (event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer && randy.nextInt(30) <= (2 + event.lootingLevel * 2)) @@ -452,10 +469,30 @@ public class FMEventHandler { } } - /*@SubscribeEvent + @SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event){ - - }*/ + if(Compat.bm && event.entityLiving != null && event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote){ + EntityPlayer player = (EntityPlayer)event.entityLiving; + String name = player.getDisplayName(); + if(player.isPotionActive(DarkPotions.bloodSeal)){ + try { + if (lastLP.containsKey(name)) { + if (SoulNetworkHandler.getCurrentEssence(name) > lastLP.get(name)) + SoulNetworkHandler.setCurrentEssence(name, lastLP.get(name)); + else + lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name)); + } + else + lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name)); + } + catch(Throwable e){ + Compat.bm = false; + } + } + else if(lastLP.containsKey(name)) + lastLP.remove(name); + } + } @SubscribeEvent public void onCrafting(ItemCraftedEvent event) { @@ -468,6 +505,12 @@ public class FMEventHandler { } } } + if(Compat.bm && event.crafting.getItem() == ForbiddenItems.bloodOrb){ + EntityItem ent = event.player.entityDropItem(new ItemStack(ConfigItems.itemEldritchObject, 1, 3), 0); + ent.motionY += randy.nextFloat() * 0.05F; + ent.motionX += (randy.nextFloat() - randy.nextFloat()) * 0.1F; + ent.motionZ += (randy.nextFloat() - randy.nextFloat()) * 0.1F; + } } } \ No newline at end of file diff --git a/src/main/java/fox/spiteful/forbidden/Forbidden.java b/src/main/java/fox/spiteful/forbidden/Forbidden.java index 47aae65..6cad052 100644 --- a/src/main/java/fox/spiteful/forbidden/Forbidden.java +++ b/src/main/java/fox/spiteful/forbidden/Forbidden.java @@ -1,6 +1,7 @@ package fox.spiteful.forbidden; import cpw.mods.fml.common.FMLCommonHandler; +import fox.spiteful.forbidden.potions.DarkPotions; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -20,7 +21,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -@Mod(modid = "ForbiddenMagic", name = "Forbidden Magic", dependencies = "required-after:Thaumcraft@[4.2.2.0,);after:ThaumicTinkerer;after:Botania") +@Mod(modid = "ForbiddenMagic", name = "Forbidden Magic", dependencies = "required-after:Thaumcraft@[4.2.2.0,);after:ThaumicTinkerer;after:AWWayofTime;after:Botania") public class Forbidden { @Instance("ForbiddenMagic") public static Forbidden instance; @@ -53,6 +54,8 @@ public class Forbidden { ForbiddenItems.addItems(); ForbiddenBlocks.addBlocks(); DarkEnchantments.hex(); + if(Compat.bm) + DarkPotions.alchemize(); proxy.registerRenderInfo(); } diff --git a/src/main/java/fox/spiteful/forbidden/ForbiddenResearch.java b/src/main/java/fox/spiteful/forbidden/ForbiddenResearch.java index 9141300..550b54a 100644 --- a/src/main/java/fox/spiteful/forbidden/ForbiddenResearch.java +++ b/src/main/java/fox/spiteful/forbidden/ForbiddenResearch.java @@ -40,7 +40,7 @@ public class ForbiddenResearch { (new DarkResearchItem("CONSUMING", "FORBIDDEN", (new AspectList()).add(Aspect.VOID, 4).add(Aspect.ENTROPY, 3).add(Aspect.MAGIC, 2), -4, -8, 1, new ResourceLocation("forbidden", "textures/misc/consuming.png"))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.CONSUMING.1"), new ResearchPage((InfusionEnchantmentRecipe) recipes.get("Consuming")) }).setParents(new String[] { "INFUSIONENCHANTMENT" }).setSecondary().setConcealed().registerResearchItem(); (new DarkResearchItem("EDUCATIONAL", "FORBIDDEN", (new AspectList()).add(Aspect.MIND, 5).add(Aspect.WEAPON, 1).add(Aspect.MAGIC, 3), -4, -7, 2, new ResourceLocation("forbidden", "textures/misc/educational.png"))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.EDUCATIONAL.1"), new ResearchPage((InfusionEnchantmentRecipe) recipes.get("Educational")) }).setParents(new String[] { "INFUSIONENCHANTMENT" }).setSecondary().setConcealed().registerResearchItem(); - if(Compat.botan || Compat.am2) + if(Compat.botan || Compat.bm || Compat.am2) (new DarkResearchItem("SCHOOLS", "FORBIDDEN", new AspectList(), -1, 1, 0, new ItemStack(Blocks.enchanting_table))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.SCHOOLS.1") }).setRound().setStub().setAutoUnlock().registerResearchItem(); } diff --git a/src/main/java/fox/spiteful/forbidden/compat/BloodMagic.java b/src/main/java/fox/spiteful/forbidden/compat/BloodMagic.java new file mode 100644 index 0000000..0bf76e0 --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/compat/BloodMagic.java @@ -0,0 +1,169 @@ +package fox.spiteful.forbidden.compat; + +import WayofTime.alchemicalWizardry.api.alchemy.AlchemicalPotionCreationHandler; +import WayofTime.alchemicalWizardry.api.bindingRegistry.BindingRegistry; +import WayofTime.alchemicalWizardry.api.rituals.Rituals; +import fox.spiteful.forbidden.Config; +import fox.spiteful.forbidden.DarkAspects; +import fox.spiteful.forbidden.LogHandler; +import fox.spiteful.forbidden.potions.DarkPotions; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.logging.log4j.Level; + +import thaumcraft.api.ItemApi; +import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.crafting.IArcaneRecipe; +import thaumcraft.api.crafting.InfusionRecipe; +import thaumcraft.api.potions.PotionFluxTaint; +import thaumcraft.api.research.ResearchPage; +import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry; + +import fox.spiteful.forbidden.DarkResearchItem; +import fox.spiteful.forbidden.items.ForbiddenItems; + +import cpw.mods.fml.common.FMLLog; +import thaumcraft.common.config.ConfigItems; + +public class BloodMagic { + public static void stab() { + try { + + AspectList list; + Item masterOrb = Compat.getItem("AWWayofTime", "masterBloodOrb"); + Item imbuedSlate = Compat.getItem("AWWayofTime", "imbuedSlate"); + Item magicales = Compat.getItem("AWWayofTime", "magicales"); + Item aether = Compat.getItem("AWWayofTime", "aether"); + Item terrae = Compat.getItem("AWWayofTime", "terrae"); + Item aquasalus = Compat.getItem("AWWayofTime", "aquasalus"); + Item incendium = Compat.getItem("AWWayofTime", "incendium"); + Item sanctus = Compat.getItem("AWWayofTime", "sanctus"); + Item tennebrae = Compat.getItem("AWWayofTime", "tennebrae"); + Item crapOrb = Compat.getItem("AWWayofTime", "weakBloodOrb"); + Item demonShard = Compat.getItem("AWWayofTime", "demonBloodShard"); + Item bloodBucket = Compat.getItem("AWWayofTime", "bucketLife"); + Item kamiOrb = Compat.getItem("AWWayofTime", "transcendentBloodOrb"); + + (new DarkResearchItem("BLOODMAGIC", "FORBIDDEN", "[BM]", new AspectList(), -1, -1, 0, new ResourceLocation("alchemicalwizardry", "textures/items/SacrificialDagger.png"))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.BLOODMAGIC.1")}).setParents(new String [] {"SCHOOLS"}).setRound().setStub().setAutoUnlock().registerResearchItem(); + + if(Config.crossWand) { + + AltarRecipeRegistry.registerAltarRecipe(new ItemStack(ForbiddenItems.wandCore, 1, 3), new ItemStack(ForbiddenItems.wandCore, 1, 6), 4, 20000, 15, 20, false); + + InfusionRecipe blood_recipe = ThaumcraftApi.addInfusionCraftingRecipe("ROD_blood", new ItemStack(ForbiddenItems.wandCore, 1, 6), 2, (new AspectList()).add(Aspect.LIFE, 32).add(Aspect.MAGIC, 12).add(Aspect.WATER, 16), new ItemStack(masterOrb), new ItemStack[]{new ItemStack(magicales), new ItemStack(imbuedSlate), new ItemStack(imbuedSlate), new ItemStack(tennebrae), new ItemStack(sanctus), new ItemStack(aquasalus), new ItemStack(incendium), new ItemStack(terrae), new ItemStack(aether)}); + (new DarkResearchItem("ROD_blood", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 5).add(Aspect.WATER, 4).add(Aspect.WEAPON, 3), -1, -3, 3, new ItemStack(ForbiddenItems.wandCore, 1, 3))).setPages(new ResearchPage[]{new ResearchPage("forbidden.research_page.ROD_blood.1"), new ResearchPage(blood_recipe), new ResearchPage("forbidden.research_page.ROD_blood.2")}).setParents(new String[]{"ROD_silverwood", "INFUSION", "BLOODMAGIC"}).setConcealed().registerResearchItem(); + ThaumcraftApi.addWarpToResearch("ROD_blood", 2); + + IArcaneRecipe blood_staff = ThaumcraftApi.addArcaneCraftingRecipe("ROD_blood_staff", new ItemStack(ForbiddenItems.wandCore, 1, 9), (new AspectList()).add(Aspect.ENTROPY, 26).add(Aspect.FIRE, 26).add(Aspect.WATER, 26).add(Aspect.AIR, 26).add(Aspect.EARTH, 26).add(Aspect.ORDER, 26), new Object[]{"__D", "_B_", "B__", Character.valueOf('B'), new ItemStack(ForbiddenItems.wandCore, 1, 3), Character.valueOf('D'), new ItemStack(demonShard)}); + (new DarkResearchItem("ROD_blood_staff", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 8).add(Aspect.WATER, 7).add(Aspect.WEAPON, 6), -3, -2, 2, new ItemStack(ForbiddenItems.wandCore, 1, 9))).setPages(new ResearchPage[]{new ResearchPage("forbidden.research_page.ROD_blood_staff.1"), new ResearchPage(blood_staff)}).setParents(new String[]{"ROD_silverwood_staff", "ROD_blood"}).setSpecial().setConcealed().registerResearchItem(); + + InfusionRecipe alchemical_recipe = ThaumcraftApi.addInfusionCraftingRecipe("CAP_alchemical", new ItemStack(ForbiddenItems.wandCap, 1, 0), 3, (new AspectList()).add(Aspect.LIFE, 12).add(Aspect.WATER, 6), ItemApi.getItem("itemWandCap", 1), new ItemStack[] { new ItemStack(magicales), new ItemStack(magicales), new ItemStack(magicales) }); + (new DarkResearchItem("CAP_alchemical", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 4).add(Aspect.TOOL, 1).add(Aspect.WATER, 3), -3, -3, 2, new ItemStack(ForbiddenItems.wandCap, 1, 0))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.CAP_alchemical.1"), new ResearchPage(alchemical_recipe) }).setParents(new String[] { "ROD_blood", "CAP_gold" }).setSecondary().setConcealed().registerResearchItem(); + + } + + IArcaneRecipe bloodwell_recipe = ThaumcraftApi.addShapelessArcaneCraftingRecipe("BLOODWELL", new ItemStack(ForbiddenItems.bloodwell, 1, 0), (new AspectList()).add(Aspect.WATER, 10).add(Aspect.EARTH, 10), new Object[] { new ItemStack(Items.feather, 1, 0), new ItemStack(bloodBucket, 1, 0), new ItemStack(Items.glass_bottle, 1, 0), new ItemStack(crapOrb, 1, 0) }); + (new DarkResearchItem("BLOODWELL", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 5).add(Aspect.MIND, 4).add(Aspect.SENSES, 3), 1, -1, 1, new ItemStack(ForbiddenItems.bloodwell, 1, 0))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.BLOODWELL.1"), new ResearchPage(bloodwell_recipe) }).setParents(new String[] { "BLOODMAGIC" }).registerResearchItem(); + + InfusionRecipe blood_rapier = ThaumcraftApi.addInfusionCraftingRecipe("BLOODRAPIER", new ItemStack(ForbiddenItems.bloodRapier, 1, 0), 8, (new AspectList()).add(Aspect.LIFE, 18).add(Aspect.HUNGER, 32).add(Aspect.WEAPON, 8), ItemApi.getItem("itemSwordVoid", 0), new ItemStack[] { new ItemStack(ConfigItems.itemResource, 1, 12), new ItemStack(ForbiddenItems.deadlyShards, 1, 0), new ItemStack(ForbiddenItems.gluttonyShard, 1, 0), new ItemStack(Items.feather), new ItemStack(ConfigItems.itemResource, 1, 6) }); + (new DarkResearchItem("BLOODRAPIER", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 16).add(Aspect.HUNGER, 12).add(Aspect.WEAPON, 12).add(Aspect.MAGIC, 12), 1, -2, 3, new ItemStack(ForbiddenItems.bloodRapier, 1, 0))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.BLOODRAPIER.1"), new ResearchPage(blood_rapier) }).setParents(new String[] { "BLOODMAGIC", "INFUSION", "VOIDMETAL" }).setConcealed().registerResearchItem(); + ThaumcraftApi.addWarpToResearch("BLOODRAPIER", 2); + ThaumcraftApi.addWarpToItem(new ItemStack(ForbiddenItems.bloodRapier), 2); + + InfusionRecipe eldritch_orb = ThaumcraftApi.addInfusionCraftingRecipe("ELDRITCHORB", new ItemStack(ForbiddenItems.bloodOrb, 1, 0), 2, (new AspectList()).add(Aspect.LIFE, 64).add(Aspect.ELDRITCH, 48).add(Aspect.DARKNESS, 32).add(Aspect.VOID, 64), new ItemStack(kamiOrb), new ItemStack[] { new ItemStack(ConfigItems.itemEldritchObject, 1, 3), new ItemStack(ConfigItems.itemEldritchObject, 1, 0), new ItemStack(ConfigItems.itemShard, 1, 6), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(Items.nether_star), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigItems.itemShard, 1, 6), new ItemStack(ConfigItems.itemEldritchObject, 1, 0) }); + (new DarkResearchItem("ELDRITCHORB", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 24).add(Aspect.VOID, 32).add(Aspect.CRYSTAL, 24).add(Aspect.ELDRITCH, 12), 1, -3, 4, new ItemStack(ForbiddenItems.bloodOrb, 1, 0))).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.ELDRITCHORB.1"), new ResearchPage(eldritch_orb) }).setParents(new String[] { "BLOODMAGIC", "INFUSION", "PRIMPEARL", "VOIDMETAL" }).setConcealed().setSpecial().registerResearchItem(); + ThaumcraftApi.addWarpToResearch("ELDRITCHORB", 3); + ThaumcraftApi.addWarpToItem(new ItemStack(ForbiddenItems.bloodOrb), 5); + + BindingRegistry.registerRecipe(new ItemStack(ForbiddenItems.boundwell, 1, 0), new ItemStack(ForbiddenItems.crystalwell, 1, 0)); + AlchemicalPotionCreationHandler.addPotion(new ItemStack(ConfigItems.itemResource, 1, 11), PotionFluxTaint.instance.getId(), 450); + AlchemicalPotionCreationHandler.addPotion(new ItemStack(ForbiddenItems.resource, 1, 3), DarkPotions.bloodSeal.getId(), 1200); + + Rituals.registerRitual("SpiteSanity", 1, 20000, new RitualSanity(), "Plea of Delayed Insanity"); + + list = (new AspectList()).add(Aspect.LIFE, 2).add(Aspect.MAGIC, 2).add(Aspect.CRYSTAL, 4); + ThaumcraftApi.registerObjectTag(new ItemStack(crapOrb, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.LIFE, 4).add(Aspect.MAGIC, 4).add(Aspect.CRYSTAL, 4); + aspectBloodItem("apprenticeBloodOrb", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.LIFE, 6).add(Aspect.MAGIC, 6).add(Aspect.CRYSTAL, 4); + aspectBloodItem("magicianBloodOrb", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.LIFE, 16).add(Aspect.MAGIC, 8).add(Aspect.CRYSTAL, 4); + ThaumcraftApi.registerObjectTag(new ItemStack(masterOrb, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.LIFE, 16).add(DarkAspects.NETHER, 8).add(Aspect.CRYSTAL, 4).add(Aspect.FIRE, 1).add(Aspect.WATER, 1).add(Aspect.AIR, 1).add(Aspect.EARTH, 1).add(Aspect.LIGHT, 1).add(Aspect.DARKNESS, 1); + ThaumcraftApi.registerObjectTag(new ItemStack(demonShard, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.LIFE, 32).add(DarkAspects.NETHER, 4).add(Aspect.MAGIC, 8).add(Aspect.CRYSTAL, 4); + aspectBloodItem("archmageBloodOrb", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.LIFE, 32).add(DarkAspects.NETHER, 16).add(Aspect.MAGIC, 16).add(Aspect.CRYSTAL, 16); + ThaumcraftApi.registerObjectTag(new ItemStack(kamiOrb, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.ELDRITCH, 5).add(Aspect.WEAPON, 5).add(DarkAspects.WRATH, 5).add(Aspect.POISON, 1); + aspectBloodItem("energySword", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.ELDRITCH, 5).add(Aspect.WEAPON, 6).add(DarkAspects.WRATH, 6).add(Aspect.POISON, 1); + aspectBloodItem("energyBlaster", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.ELDRITCH, 6).add(Aspect.MINE, 5).add(DarkAspects.WRATH, 4).add(Aspect.TRAP, 4); + aspectBloodItem("boundPickaxe", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.ELDRITCH, 4).add(Aspect.TOOL, 5).add(DarkAspects.WRATH, 2).add(Aspect.TRAP, 2); + aspectBloodItem("boundShovel", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.ELDRITCH, 6).add(Aspect.TOOL, 5).add(DarkAspects.WRATH, 4).add(Aspect.TRAP, 4); + aspectBloodItem("boundAxe", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.METAL, 8).add(Aspect.VOID, 1).add(Aspect.LIFE, 4); + ThaumcraftApi.registerObjectTag(new ItemStack(bloodBucket, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.LIGHT, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(sanctus, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.DARKNESS, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(tennebrae, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.MAGIC, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(magicales, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.AIR, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(aether, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.EARTH, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(terrae, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.WATER, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(aquasalus, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.FIRE, 6).add(Aspect.ENERGY, 3); + ThaumcraftApi.registerObjectTag(new ItemStack(incendium, 1, OreDictionary.WILDCARD_VALUE), list); + + list = (new AspectList()).add(Aspect.COLD, 6).add(Aspect.ENERGY, 3); + aspectBloodItem("crystallos", OreDictionary.WILDCARD_VALUE, list); + + list = (new AspectList()).add(Aspect.ENTROPY, 6).add(Aspect.ENERGY, 3); + aspectBloodItem("crepitous", OreDictionary.WILDCARD_VALUE, list); + } catch (Throwable e) { + LogHandler.log(Level.INFO, e, "Forbidden Magic tried to do some Blood Magic, but bled out."); + Compat.bm = false; + } + } + + private static void aspectBloodItem(String target, int damage, AspectList list) { + try { + Item item = Compat.getItem("AWWayofTime", target); + ThaumcraftApi.registerObjectTag(new ItemStack(item, 1, damage), list); + } catch (Exception e) { + FMLLog.log(Level.INFO, e, "Forbidden Magic was unable to add aspects to " + target); + } + } +} diff --git a/src/main/java/fox/spiteful/forbidden/compat/Compat.java b/src/main/java/fox/spiteful/forbidden/compat/Compat.java index 7ec8b7e..a99628c 100644 --- a/src/main/java/fox/spiteful/forbidden/compat/Compat.java +++ b/src/main/java/fox/spiteful/forbidden/compat/Compat.java @@ -42,6 +42,7 @@ public class Compat { public static boolean tt = false; public static boolean kami = false; public static boolean natura = false; + public static boolean bm = false; public static boolean am2 = false; public static boolean botan = false; public static boolean special = false; @@ -53,6 +54,7 @@ public class Compat { tt = Config.tt && Loader.isModLoaded("ThaumicTinkerer"); kami = tt && Loader.isModLoaded("ThaumicTinkererKami"); natura = Loader.isModLoaded("Natura"); + bm = Config.bloodMagic && Loader.isModLoaded("AWWayofTime"); am2 = Config.am2 && Loader.isModLoaded("arsmagica2"); botan = Config.botan && Loader.isModLoaded("Botania"); special = Config.wrathCage && Config.special && Loader.isModLoaded("SpecialMobs"); @@ -136,6 +138,10 @@ public class Compat { } } + if (bm) { + BloodMagic.stab(); + } + if (Config.crossWand && am2) { try { Class amItems = Class.forName("am2.items.ItemsCommonProxy"); diff --git a/src/main/java/fox/spiteful/forbidden/compat/ForbiddenBotany.java b/src/main/java/fox/spiteful/forbidden/compat/ForbiddenBotany.java index 4132a7c..7d375ed 100644 --- a/src/main/java/fox/spiteful/forbidden/compat/ForbiddenBotany.java +++ b/src/main/java/fox/spiteful/forbidden/compat/ForbiddenBotany.java @@ -1,10 +1,12 @@ package fox.spiteful.forbidden.compat; +import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry; import cpw.mods.fml.common.registry.GameRegistry; import fox.spiteful.forbidden.Config; import fox.spiteful.forbidden.DarkResearchItem; import fox.spiteful.forbidden.LogHandler; import fox.spiteful.forbidden.items.ForbiddenItems; +import fox.spiteful.forbidden.tiles.SubTileBloodthorn; import fox.spiteful.forbidden.tiles.SubTileEuclidaisy; import fox.spiteful.forbidden.tiles.SubTileTainthistle; import fox.spiteful.forbidden.tiles.SubTileWhisperweed; @@ -116,6 +118,29 @@ public class ForbiddenBotany { InfusionRecipe thistlecraft = ThaumcraftApi.addInfusionCraftingRecipe("TAINTHISTLE", tainthistle, 4, (new AspectList()).add(Aspect.TAINT, 8).add(Aspect.HUNGER, 4).add(Aspect.AIR, 4).add(Aspect.WATER, 4), new ItemStack(ConfigItems.itemResource, 1, 12), new ItemStack[] { new ItemStack(petal, 1, 10), new ItemStack(manaPetal, 1, 10), new ItemStack(manaPetal, 1, 10), new ItemStack(rune, 1, 10), new ItemStack(rune, 1, 8)}); (new DarkResearchItem("TAINTHISTLE", "FORBIDDEN", "[B]", (new AspectList()).add(Aspect.PLANT, 8).add(Aspect.TAINT, 10).add(Aspect.MAGIC, 4), -2, 5, 2, tainthistle)).setPages(new ResearchPage[] { new ResearchPage("forbidden.research_page.TAINTHISTLE.1"), new ResearchPage(thistlecraft) }).setParents(new String[] { "BOTANY", "INFUSION" }).setConcealed().registerResearchItem(); + if(Compat.bm){ + BotaniaAPI.registerSubTile("bloodthorn", SubTileBloodthorn.class); + BotaniaAPI.registerSubTileSignature(SubTileBloodthorn.class, new DarkSignature("bloodthorn")); + BotaniaAPI.addSubTileToCreativeMenu("bloodthorn"); + + SubTileBloodthorn.lexicon = new ForbiddenLexicon("bloodthorn", functional){ + @Override + public String getSubtitle(){ + return "[Forbidden Magic][Blood Magic]"; + } + }; + + SubTileBloodthorn.lexicon.addPage(BotaniaAPI.internalHandler.textPage("forbidden.lexicon.bloodthorn.0")); + + ItemStack bloodthorn = getFlower("bloodthorn"); + try{ + AltarRecipeRegistry.registerAltarRecipe(bloodthorn, new ItemStack(flower, 1, 14), 4, 15000, 25, 50, false); + } + catch(Throwable e){ + LogHandler.log(Level.INFO, e, "Forbidden Magic tried to do some Blood Magic, but bled out."); + } + } + ThaumcraftApi.registerObjectTag(new ItemStack(Compat.getItem("Botania", "specialFlower"), 1), (new AspectList()).add(Aspect.PLANT, 4).add(Aspect.MAGIC, 1)); } catch (Throwable e) { diff --git a/src/main/java/fox/spiteful/forbidden/compat/RitualSanity.java b/src/main/java/fox/spiteful/forbidden/compat/RitualSanity.java new file mode 100644 index 0000000..28d5d15 --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/compat/RitualSanity.java @@ -0,0 +1,135 @@ +package fox.spiteful.forbidden.compat; + +import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry; +import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; +import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; +import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import thaumcraft.common.Thaumcraft; +import thaumcraft.common.lib.potions.PotionWarpWard; + +import java.util.ArrayList; +import java.util.List; + +public class RitualSanity extends RitualEffect +{ + public static final int crystallosDrain = 4; + + @Override + public void performEffect(IMasterRitualStone ritualStone) + { + String owner = ritualStone.getOwner(); + + int currentEssence = SoulNetworkHandler.getCurrentEssence(owner); + World world = ritualStone.getWorld(); + int x = ritualStone.getXCoord(); + int y = ritualStone.getYCoord(); + int z = ritualStone.getZCoord(); + + int timeDelay = 600; + + if (world.getWorldTime() % timeDelay != 0) + { + return; + } + + boolean crazy = world.getWorldTime() % (timeDelay * 4) == 0; + + boolean hasCrystallos = this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, false); + + int range = 15 * (hasCrystallos ? 3 : 1); + int vertRange = 15 * (hasCrystallos ? 3 : 1); + + float posX = x + 0.5f; + float posY = y + 0.5f; + float posZ = z + 0.5f; + List list = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, vertRange, range)); + int entityCount = 0; + + for (EntityPlayer player : list) + { + entityCount ++; + } + + int cost = this.getCostPerRefresh(); + + if (currentEssence < cost * entityCount) + { + SoulNetworkHandler.causeNauseaToPlayer(owner); + + } else + { + entityCount = 0; + + for (EntityPlayer player : list) + { + PotionEffect effect = player.getActivePotionEffect(PotionWarpWard.instance); + if (effect == null || effect.getDuration() <= timeDelay) + { + PotionEffect ward = new PotionEffect(PotionWarpWard.instance.id, timeDelay + 2, 0, true); + effect.getCurativeItems().clear(); + player.addPotionEffect(ward); + entityCount++; + if(crazy && world.rand.nextInt(35) <= 3) + Thaumcraft.proxy.getPlayerKnowledge().addWarpTemp(player.getDisplayName(), 1 + world.rand.nextInt(3)); + } + } + + if (entityCount > 0) + { + if (hasCrystallos) + { + this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, true); + } + SoulNetworkHandler.syphonFromNetwork(owner, cost * entityCount); + } + } + } + + @Override + public int getCostPerRefresh() + { + return 15000; + } + + @Override + public List getRitualComponentList() + { + ArrayList sanityRitual = new ArrayList(); + sanityRitual.add(new RitualComponent(4, 1, 0, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(-4, 1, 0, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(0, 1, 4, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(0, 1, -4, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(4, 2, 0, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(-4, 2, 0, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(0, 2, 4, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(0, 2, -4, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(4, 3, 0, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(-4, 3, 0, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(0, 3, 4, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(0, 3, -4, RitualComponent.DUSK)); + sanityRitual.add(new RitualComponent(4, 4, 0, RitualComponent.AIR)); + sanityRitual.add(new RitualComponent(-4, 4, 0, RitualComponent.AIR)); + sanityRitual.add(new RitualComponent(0, 4, 4, RitualComponent.AIR)); + sanityRitual.add(new RitualComponent(0, 4, -4, RitualComponent.AIR)); + sanityRitual.add(new RitualComponent(4, 4, 1, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(-4, 4, 1, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(1, 4, 4, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(1, 4, -4, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(4, 4, -1, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(-4, 4, -1, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(-1, 4, 4, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(-1, 4, -4, RitualComponent.EARTH)); + sanityRitual.add(new RitualComponent(3, 4, 0, RitualComponent.FIRE)); + sanityRitual.add(new RitualComponent(-3, 4, 0, RitualComponent.FIRE)); + sanityRitual.add(new RitualComponent(0, 4, 3, RitualComponent.FIRE)); + sanityRitual.add(new RitualComponent(0, 4, -3, RitualComponent.FIRE)); + + return sanityRitual; + } +} \ No newline at end of file diff --git a/src/main/java/fox/spiteful/forbidden/items/ForbiddenItems.java b/src/main/java/fox/spiteful/forbidden/items/ForbiddenItems.java index 1fd4dc7..ea31f71 100644 --- a/src/main/java/fox/spiteful/forbidden/items/ForbiddenItems.java +++ b/src/main/java/fox/spiteful/forbidden/items/ForbiddenItems.java @@ -50,6 +50,11 @@ public class ForbiddenItems { public static Item blinkFocus; + public static Item bloodRapier; + public static Item bloodwell; + public static Item bloodOrb; + public static Item boundwell; + public static WandRod WAND_ROD_TAINTED; public static WandRod WAND_ROD_INFERNAL; public static WandRod WAND_ROD_NEUTRONIUM; @@ -124,11 +129,11 @@ public class ForbiddenItems { WAND_ROD_INFERNAL = new WandRod("infernal", 150, new ItemStack(wandCore, 1, 1), 12, new InfernalWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_infernal.png")); WAND_ROD_NEUTRONIUM = new WandRod("neutronium", 9001, new ItemStack(Blocks.bedrock, 1), 1000, new CreativeWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_neutronium.png")); WAND_ROD_NEUTRONIUM.setGlowing(true); - WAND_ROD_BLOOD = new WandRod("blood", 100, new ItemStack(wandCore, 1, 3), 12, new ResourceLocation("forbidden", "textures/models/wand_rod_blood.png")); + WAND_ROD_BLOOD = new WandRod("blood", 100, new ItemStack(wandCore, 1, 3), 12, new BloodWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_blood.png")); WAND_ROD_WITCHWOOD = new WandRod("witchwood", 100, new ItemStack(wandCore, 1, 4), 12, new ManaWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_witchwood.png")); WAND_ROD_LIVINGWOOD = new WandRod("livingwood", 100, new ItemStack(wandCore, 1, 7), 12, new YandereWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_livingwood.png")); WAND_ROD_DREAMWOOD = new WandRod("dreamwood", 100, new ItemStack(wandCore, 1, 11), 12, new YandereWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_dreamwood.png")); - STAFF_ROD_BLOOD = new StaffRod("blood", 50, new ItemStack(wandCore, 1, 9), 24, new ResourceLocation("forbidden", "textures/models/wand_rod_blood.png")); + STAFF_ROD_BLOOD = new StaffRod("blood", 50, new ItemStack(wandCore, 1, 9), 24, new BloodStaffUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_blood.png")); STAFF_ROD_NEUTRONIUM = new StaffRod("neutronium", 9002, new ItemStack(Blocks.bedrock, 1), 1000, new CreativeWandUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_neutronium.png")); STAFF_ROD_NEUTRONIUM.setGlowing(true); STAFF_ROD_WITCHWOOD = new StaffRod("witchwood", 50, new ItemStack(wandCore, 1, 10), 24, new ManaStaffUpdate(), new ResourceLocation("forbidden", "textures/models/wand_rod_witchwood.png")); @@ -146,6 +151,24 @@ public class ForbiddenItems { OreDictionary.registerOre("nuggetEmerald", new ItemStack(resource, 1, 0)); OreDictionary.registerOre("dyeBlack", new ItemStack(resource, 1, 1)); + if (Compat.bm) { + try { + bloodwell = new ItemBloodwell().setUnlocalizedName("Bloodwell"); + GameRegistry.registerItem(bloodwell, "Bloodwell"); + + bloodOrb = new ItemDivineOrb().setUnlocalizedName("EldritchOrb"); + GameRegistry.registerItem(bloodOrb, "EldritchOrb"); + + boundwell = new ItemBoundwell().setUnlocalizedName("Boundwell"); + GameRegistry.registerItem(boundwell, "Boundwell"); + + bloodRapier = new ItemBloodRapier().setUnlocalizedName("BloodRapier"); + GameRegistry.registerItem(bloodRapier, "BloodRapier"); + } catch (Throwable e) { + e.printStackTrace(); + } + } + crystalwell = new ItemCrystalwell().setUnlocalizedName("Crystalwell"); GameRegistry.registerItem(crystalwell, "Crystalwell"); diff --git a/src/main/java/fox/spiteful/forbidden/items/ItemDivineOrb.java b/src/main/java/fox/spiteful/forbidden/items/ItemDivineOrb.java new file mode 100644 index 0000000..b97b128 --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/items/ItemDivineOrb.java @@ -0,0 +1,112 @@ +package fox.spiteful.forbidden.items; + +import java.util.List; + +import fox.spiteful.forbidden.Forbidden; +import fox.spiteful.forbidden.compat.Compat; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import thaumcraft.api.IWarpingGear; + +public class ItemDivineOrb extends Item implements IBloodOrb, IBindable, IWarpingGear { + public ItemDivineOrb() { + setMaxStackSize(1); + setCreativeTab(Forbidden.tab); + AltarRecipeRegistry.registerAltarOrbRecipe(new ItemStack(this), 6, 140); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon("forbidden:divineorb"); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(StatCollector.translateToLocal("tooltip.divineorb")); + + if (!(stack.stackTagCompound == null)) { + list.add(StatCollector.translateToLocal("tooltip.currentowner") + " " + stack.stackTagCompound.getString("ownerName")); + } + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + if (Compat.bm) + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + + if (world != null) { + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; + world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + } + if (!world.isRemote) { + return itemstack; + } + + NBTTagCompound itemTag = itemstack.stackTagCompound; + + if (itemTag == null || itemTag.getString("ownerName").equals("")) { + return itemstack; + } + + if(!player.capabilities.isCreativeMode) + player.setHealth(player.getHealth() - 1); + SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 200, 700000000); + + return itemstack; + } + + @Override + public int getMaxEssence() { + return 80000000; + } + + @Override + public int getOrbLevel() { + return 6; + } + + @Override + public int getWarp(ItemStack itemstack, EntityPlayer player) { + return 5; + } + + @Override + public EnumRarity getRarity(ItemStack itemstack) { + return EnumRarity.epic; + } + + @Override + public boolean hasContainerItem() + { + return true; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) + { + return false; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { + return itemStack; + } +} \ No newline at end of file diff --git a/src/main/java/fox/spiteful/forbidden/items/baubles/ItemSubCollar.java b/src/main/java/fox/spiteful/forbidden/items/baubles/ItemSubCollar.java index c7debec..a9577a2 100644 --- a/src/main/java/fox/spiteful/forbidden/items/baubles/ItemSubCollar.java +++ b/src/main/java/fox/spiteful/forbidden/items/baubles/ItemSubCollar.java @@ -4,6 +4,8 @@ import baubles.common.lib.PlayerHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fox.spiteful.forbidden.Forbidden; +import fox.spiteful.forbidden.compat.Compat; +import fox.spiteful.forbidden.potions.DarkPotions; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -13,6 +15,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; diff --git a/src/main/java/fox/spiteful/forbidden/items/scribes/ItemBloodwell.java b/src/main/java/fox/spiteful/forbidden/items/scribes/ItemBloodwell.java new file mode 100644 index 0000000..2a23f8d --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/items/scribes/ItemBloodwell.java @@ -0,0 +1,91 @@ +package fox.spiteful.forbidden.items.scribes; + +import java.util.List; + +import fox.spiteful.forbidden.Forbidden; +import fox.spiteful.forbidden.compat.Compat; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import thaumcraft.api.IScribeTools; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemBloodwell extends Item implements IScribeTools, IBindable { + + @SideOnly(Side.CLIENT) + public IIcon icon; + + public ItemBloodwell() { + maxStackSize = 1; + canRepair = false; + setMaxDamage(5); + setCreativeTab(Forbidden.tab); + setHasSubtypes(false); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister ir) { + this.icon = ir.registerIcon("forbidden:bloodwell"); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int par1) { + return this.icon; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity fauxplayer, int z, boolean par5) { + if (Compat.bm && stack.getItemDamage() > 0 && stack.hasTagCompound()) { + EntityPlayer player = null; + if (fauxplayer instanceof EntityPlayer) + player = (EntityPlayer) fauxplayer; + else + return; + + if (player.capabilities.isCreativeMode) + stack.setItemDamage(0); + else if (SoulNetworkHandler.syphonFromNetwork(stack, 25) > 0) + stack.setItemDamage(stack.getItemDamage() - 1); + else if (player.getHealth() > 6) { + player.setHealth(player.getHealth() - 2); + stack.setItemDamage(stack.getItemDamage() - 1); + } + } + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + return itemstack; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean z) { + if (stack.hasTagCompound()) { + list.add(""); + list.add(StatCollector.translateToLocal("tooltip.currentowner") + " " + stack.stackTagCompound.getString("ownerName")); + } + } + + @Override + public void setDamage(ItemStack stack, int damage) { + if (damage > 0) { + if (SoulNetworkHandler.syphonFromNetwork(stack, 25 * damage) > 0) + super.setDamage(stack, 0); + else + super.setDamage(stack, damage); + } else + super.setDamage(stack, damage); + } +} \ No newline at end of file diff --git a/src/main/java/fox/spiteful/forbidden/items/scribes/ItemBoundwell.java b/src/main/java/fox/spiteful/forbidden/items/scribes/ItemBoundwell.java new file mode 100644 index 0000000..b86a9ea --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/items/scribes/ItemBoundwell.java @@ -0,0 +1,97 @@ +package fox.spiteful.forbidden.items.scribes; + +import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fox.spiteful.forbidden.Forbidden; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import thaumcraft.api.IScribeTools; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.common.Thaumcraft; +import thaumcraft.common.lib.network.PacketHandler; +import thaumcraft.common.lib.network.playerdata.PacketAspectPool; +import thaumcraft.common.lib.research.ResearchManager; + +import java.util.Iterator; +import java.util.List; + +public class ItemBoundwell extends Item implements IScribeTools, IBindable{ + @SideOnly(Side.CLIENT) + public IIcon icon; + + public ItemBoundwell() { + maxStackSize = 1; + canRepair = false; + setMaxDamage(100); + setCreativeTab(Forbidden.tab); + setHasSubtypes(false); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister ir) { + this.icon = ir.registerIcon("forbidden:boundwell"); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int par1) { + return this.icon; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + if (itemstack.getItemDamage() >= 100) { + player.swingItem(); + if (!world.isRemote) { + if (player.capabilities.isCreativeMode) + itemstack.setItemDamage(0); + else { + SoulNetworkHandler.syphonAndDamageFromNetwork(itemstack, player, 10000); + if(player.getHealth() > 0){ + itemstack.setItemDamage(0); + } + else + return itemstack; + } + Aspect aspect; + short amount; + for(Iterator count = Aspect.getPrimalAspects().iterator(); count.hasNext(); PacketHandler.INSTANCE.sendTo(new PacketAspectPool(aspect.getTag(), Short.valueOf(amount), Short.valueOf(Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(player.getCommandSenderName(), aspect))), (EntityPlayerMP)player)) + { + aspect = (Aspect)count.next(); + amount = (short)(world.rand.nextInt(4) + 4); + Thaumcraft.proxy.playerKnowledge.addAspectPool(player.getCommandSenderName(), aspect, amount); + ResearchManager.scheduleSave(player); + } + } + } + return itemstack; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean z) { + if (stack.hasTagCompound()) { + list.add(""); + list.add(StatCollector.translateToLocal("tooltip.currentowner") + " " + stack.stackTagCompound.getString("ownerName")); + } + } + + /** + * Render Pass sensitive version of hasEffect() + */ + @SideOnly(Side.CLIENT) + @Override + public boolean hasEffect(ItemStack stack, int pass) { + return stack.getItemDamage() >= 100; + } + +} diff --git a/src/main/java/fox/spiteful/forbidden/items/tools/ItemBloodRapier.java b/src/main/java/fox/spiteful/forbidden/items/tools/ItemBloodRapier.java new file mode 100644 index 0000000..49a6d8d --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/items/tools/ItemBloodRapier.java @@ -0,0 +1,86 @@ +package fox.spiteful.forbidden.items.tools; + +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fox.spiteful.forbidden.compat.Compat; +import fox.spiteful.forbidden.potions.DarkPotions; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.EnumHelper; +import thaumcraft.api.IRepairable; +import thaumcraft.api.IWarpingGear; +import thaumcraft.common.config.ConfigItems; + +public class ItemBloodRapier extends ItemSword implements IRepairable, IWarpingGear{ + + static final ToolMaterial bloodsucker = EnumHelper.addToolMaterial("BLOODSUCKER", 3, 700, 10F, -3F, 18); + private IIcon icon; + + public ItemBloodRapier(){ + super(bloodsucker); + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) { + stack.damageItem(1, player); + victim.motionY *= 0.8; + if (victim.hurtResistantTime > 18) + victim.hurtResistantTime -= 5; + if (Compat.bm & victim instanceof EntityPlayer) { + String target = ((EntityPlayer) victim).getDisplayName(); + int lp = SoulNetworkHandler.getCurrentEssence(target); + int damage = Math.max(4000, lp / 4); + if (lp >= damage) + lp -= damage; + else + lp = 0; + SoulNetworkHandler.setCurrentEssence(target, lp); + victim.addPotionEffect(new PotionEffect(DarkPotions.bloodSeal.getId(), 1200)); + } + return true; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int wat, boolean fuckObfuscation) { + super.onUpdate(stack, world, entity, wat, fuckObfuscation); + if(stack.isItemDamaged() && entity != null && entity.ticksExisted % 20 == 0 && entity instanceof EntityLivingBase) { + stack.damageItem(-1, (EntityLivingBase)entity); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.icon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.icon = ir.registerIcon("forbidden:blood_rapier"); + } + + @Override + public int getWarp(ItemStack itemstack, EntityPlayer player) { + return 2; + } + + @Override + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return par2ItemStack.isItemEqual(new ItemStack(ConfigItems.itemResource, 1, 15))?true:super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @Override + public EnumRarity getRarity(ItemStack itemstack) { + return EnumRarity.rare; + } +} diff --git a/src/main/java/fox/spiteful/forbidden/items/wands/BloodStaffUpdate.java b/src/main/java/fox/spiteful/forbidden/items/wands/BloodStaffUpdate.java new file mode 100644 index 0000000..9448faf --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/items/wands/BloodStaffUpdate.java @@ -0,0 +1,82 @@ +package fox.spiteful.forbidden.items.wands; + +import fox.spiteful.forbidden.Config; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.wands.IWandRodOnUpdate; +import thaumcraft.common.items.wands.ItemWandCasting; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +import fox.spiteful.forbidden.compat.Compat; + +public class BloodStaffUpdate implements IWandRodOnUpdate { + + Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]); + + public void onUpdate(ItemStack itemstack, EntityPlayer player) + { + if(Compat.bm && Config.crossWand && player.ticksExisted % 25 == 0) + { + try + { + if(!checkHotbar(itemstack, player)) + return; + + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + + int cost; + if(((ItemWandCasting)itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical")) + cost = 900; + else + cost = 1000; + + for(int x = 0;x < primals.length;x++) + { + if(((ItemWandCasting)itemstack.getItem()).getVis(itemstack, primals[x]) < ((ItemWandCasting)itemstack.getItem()).getMaxVis(itemstack)) + { + if(player.capabilities.isCreativeMode) + ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); + else if(SoulNetworkHandler.syphonFromNetwork(itemstack, cost) > 0) + ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); + else if(syphonHealth(player)) + { + ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); + return; + } + else + return; + } + } + + } + catch(Exception e) + { + return; + } + } + + } + + public boolean syphonHealth(EntityPlayer player) + { + if(player.getHealth() > 0) + { + player.setHealth(player.getHealth() - 3); + return true; + } + else + return false; + } + + private boolean checkHotbar(ItemStack stack, EntityPlayer player) + { + for(int x = 0; x < 9; ++x) + { + ItemStack item = player.inventory.getStackInSlot(x); + if(item == stack) + return true; + } + return false; + } +} diff --git a/src/main/java/fox/spiteful/forbidden/items/wands/BloodWandUpdate.java b/src/main/java/fox/spiteful/forbidden/items/wands/BloodWandUpdate.java new file mode 100644 index 0000000..2a8c629 --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/items/wands/BloodWandUpdate.java @@ -0,0 +1,67 @@ +package fox.spiteful.forbidden.items.wands; + +import fox.spiteful.forbidden.Config; +import fox.spiteful.forbidden.compat.Compat; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.wands.IWandRodOnUpdate; +import thaumcraft.common.items.wands.ItemWandCasting; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; + +public class BloodWandUpdate implements IWandRodOnUpdate { + + Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]); + + public void onUpdate(ItemStack itemstack, EntityPlayer player) + { + if(Compat.bm && Config.crossWand && player.ticksExisted % 100 == 0) + { + try + { + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + + int cost; + if(((ItemWandCasting)itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical")) + cost = 900; + else + cost = 1000; + + for(int x = 0;x < primals.length;x++) + { + if(((ItemWandCasting)itemstack.getItem()).getVis(itemstack, primals[x]) < ((ItemWandCasting)itemstack.getItem()).getMaxVis(itemstack)) + { + if(player.capabilities.isCreativeMode) + ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); + else if(SoulNetworkHandler.syphonFromNetwork(itemstack, cost) > 0) + ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); + else if(syphonHealth(player)) + { + ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); + return; + } + else + return; + } + } + + } + catch(Throwable e) + { + return; + } + } + + } + + public boolean syphonHealth(EntityPlayer player) + { + if(player.getHealth() > 6) + { + player.setHealth(player.getHealth() - 3); + return true; + } + else + return false; + } +} diff --git a/src/main/java/fox/spiteful/forbidden/items/wands/ItemWandCores.java b/src/main/java/fox/spiteful/forbidden/items/wands/ItemWandCores.java index 0448f17..233e216 100644 --- a/src/main/java/fox/spiteful/forbidden/items/wands/ItemWandCores.java +++ b/src/main/java/fox/spiteful/forbidden/items/wands/ItemWandCores.java @@ -82,6 +82,16 @@ public class ItemWandCores extends Item { ((ItemWandCasting) wand.getItem()).setCap(wand, (WandCap) WandCap.caps.get("orichalcum")); ((ItemWandCasting) wand.getItem()).setRod(wand, (WandRod) WandRod.rods.get("neutronium_staff")); list.add(wand); + if (Compat.bm && Config.crossWand) { + wand = ItemApi.getItem("itemWandCasting", 84); + ((ItemWandCasting) wand.getItem()).setCap(wand, (WandCap) WandCap.caps.get("alchemical")); + ((ItemWandCasting) wand.getItem()).setRod(wand, (WandRod) WandRod.rods.get("blood")); + list.add(wand); + wand = ItemApi.getItem("itemWandCasting", 168); + ((ItemWandCasting) wand.getItem()).setCap(wand, (WandCap) WandCap.caps.get("alchemical")); + ((ItemWandCasting) wand.getItem()).setRod(wand, (WandRod) WandRod.rods.get("blood_staff")); + list.add(wand); + } if (Compat.am2 && Config.crossWand) { wand = ItemApi.getItem("itemWandCasting", 72); ((ItemWandCasting) wand.getItem()).setCap(wand, (WandCap) WandCap.caps.get("vinteum")); diff --git a/src/main/java/fox/spiteful/forbidden/potions/DarkPotions.java b/src/main/java/fox/spiteful/forbidden/potions/DarkPotions.java new file mode 100644 index 0000000..17b117e --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/potions/DarkPotions.java @@ -0,0 +1,38 @@ +package fox.spiteful.forbidden.potions; + +import fox.spiteful.forbidden.Config; +import net.minecraft.potion.Potion; +import net.minecraft.util.ResourceLocation; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +public class DarkPotions { + public static final ResourceLocation icons = new ResourceLocation("forbidden", "textures/misc/potions.png"); + public static Potion bloodSeal; + + public static void alchemize(){ + if(Potion.potionTypes.length < 256) { + Potion[] potionTypes = null; + for (Field f : Potion.class.getDeclaredFields()) { + f.setAccessible(true); + try { + if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { + Field modfield = Field.class.getDeclaredField("modifiers"); + modfield.setAccessible(true); + modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); + potionTypes = (Potion[]) f.get(null); + final Potion[] newPotionTypes = new Potion[256]; + System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); + f.set(null, newPotionTypes); + } + } catch (Exception e) { + System.err.println("Severe error, please report this to the mod author:"); + System.err.println(e); + } + } + } + + bloodSeal = new PotionBloodSeal(Config.bloodSealPotionID); + } +} diff --git a/src/main/java/fox/spiteful/forbidden/potions/PotionBloodSeal.java b/src/main/java/fox/spiteful/forbidden/potions/PotionBloodSeal.java new file mode 100644 index 0000000..b31c797 --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/potions/PotionBloodSeal.java @@ -0,0 +1,20 @@ +package fox.spiteful.forbidden.potions; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.potion.Potion; + +public class PotionBloodSeal extends Potion { + public PotionBloodSeal(int id){ + super(id, true, 0xAC1919); + this.setPotionName("potion.blood_seal"); + this.setIconIndex(4, 0); + } + + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() { + Minecraft.getMinecraft().renderEngine.bindTexture(DarkPotions.icons); + return super.getStatusIconIndex(); + } +} diff --git a/src/main/java/fox/spiteful/forbidden/tiles/SubTileBloodthorn.java b/src/main/java/fox/spiteful/forbidden/tiles/SubTileBloodthorn.java new file mode 100644 index 0000000..d20e659 --- /dev/null +++ b/src/main/java/fox/spiteful/forbidden/tiles/SubTileBloodthorn.java @@ -0,0 +1,69 @@ +/** + * This class based on a class created by . + * + * It was 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 15, 2014, 4:47:41 PM (GMT)] + */ + +package fox.spiteful.forbidden.tiles; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.subtile.SubTileFunctional; + +import java.util.List; + +public class SubTileBloodthorn extends SubTileFunctional { + public static LexiconEntry lexicon; + + @Override + public void onUpdate() { + super.onUpdate(); + if(redstoneSignal > 0) + return; + final int range = 6; + final int cost = 40; + List entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - range, supertile.yCoord - range, supertile.zCoord - range, supertile.xCoord + range, supertile.yCoord + range, supertile.zCoord + range)); + for(EntityLivingBase entity : entities) { + if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(Potion.weakness) == null && mana >= cost && !entity.worldObj.isRemote) { + entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2)); + mana -= cost; + } + } + } + @Override + public boolean acceptsRedstone() { + return true; + } + @Override + public int getColor() { + return 0x7D0600; + } + @Override + public int getMaxMana() { + return 360; + } + @Override + public LexiconEntry getEntry() { + return lexicon; + } + + @Override + public IIcon getIcon(){ + return BotaniaAPI.getSignatureForName("bloodthorn").getIconForStack(null); + } +} \ No newline at end of file