From 18d07baad32b618d862e31af99c2dd4c723b9b47 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Thu, 19 Mar 2015 15:26:03 -0400 Subject: [PATCH] More base-work on Omega --- .../AlchemicalWizardry.java | 6 +- .../common/AlchemicalWizardryEventHooks.java | 27 +++- .../common/book/BookParser.java | 37 +++--- .../common/items/EnergySword.java | 32 ++++- .../common/items/armour/OmegaArmour.java | 124 ++++++++++++++++++ .../common/items/armour/OmegaArmourWater.java | 58 ++++++++ .../common/items/armour/OmegaArmourWind.java | 41 ++++++ .../common/omega/OmegaParadigm.java | 22 ++++ .../common/omega/OmegaRegistry.java | 17 +++ .../common/rituals/RitualEffectOmegaTest.java | 2 +- 10 files changed, 336 insertions(+), 30 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java index b7b7e30c..979de5f3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java @@ -158,6 +158,8 @@ import WayofTime.alchemicalWizardry.common.rituals.RitualEffectLava; import WayofTime.alchemicalWizardry.common.rituals.RitualEffectLeap; import WayofTime.alchemicalWizardry.common.rituals.RitualEffectLifeConduit; import WayofTime.alchemicalWizardry.common.rituals.RitualEffectMagnetic; +import WayofTime.alchemicalWizardry.common.rituals.RitualEffectOmegaStalling; +import WayofTime.alchemicalWizardry.common.rituals.RitualEffectOmegaTest; import WayofTime.alchemicalWizardry.common.rituals.RitualEffectSoulBound; import WayofTime.alchemicalWizardry.common.rituals.RitualEffectSpawnWard; import WayofTime.alchemicalWizardry.common.rituals.RitualEffectSummonMeteor; @@ -1368,8 +1370,8 @@ public class AlchemicalWizardry Rituals.registerRitual("AW029VeilOfEvil", 1, 150000, new RitualEffectVeilOfEvil(), "Veil of Evil", new AlchemyCircleRenderer(new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), 0, 0, 0, 255, 0, 0.501, 0.501, 0, 1.5, false)); Rituals.registerRitual("AW030FullStomach", 1, 100000, new RitualEffectFullStomach(), "Requiem of the Satiated Stomach", new AlchemyCircleRenderer(new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), 0, 0, 0, 255, 0, 0.501, 0.501, 0, 1.5, false)); Rituals.registerRitual("AW031Convocation",isDemonRitualCreativeOnly ? 10 : 2, 15000000, new RitualEffectDemonPortal(), "Convocation of the Damned", new AlchemyCircleRenderer(new ResourceLocation("alchemicalwizardry:textures/models/TransCircleDemon.png"), 220, 22, 22, 255, 0, 0.501, 0.501, 0, 5, false)); -// Rituals.registerRitual("AW032", 1, 100, new RitualEffectOmegaTest(), "Symmetry of the Omega"); -// Rituals.registerRitual("AW033", 2, 100, new RitualEffectOmegaStalling(), "Omega Stalling"); + Rituals.registerRitual("AW032", 1, 100, new RitualEffectOmegaTest(), "Symmetry of the Omega"); + Rituals.registerRitual("AW033", 2, 100, new RitualEffectOmegaStalling(), "Omega Stalling"); // Rituals.registerRitual("AW034", 2, 100, new RitualEffectAlphaPact(), "Alpha Pact"); Rituals.registerRitual("AW035", 1, 10000, new RitualEffectItemRouting(), "Orchestra of the Phantom Hands"); //Rituals.registerRitual(1,100,new RitualEffectApiaryOverclock(),"Apiary Overclock")); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java b/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java index d6c5d97a..6ae766a1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java @@ -6,7 +6,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import WayofTime.alchemicalWizardry.api.event.TeleposeEvent; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -33,14 +32,17 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn; +import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.oredict.OreDictionary; import vazkii.botania.api.internal.IManaBurst; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.BloodMagicConfiguration; import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; +import WayofTime.alchemicalWizardry.api.event.TeleposeEvent; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.api.spell.APISpellHelper; import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; +import WayofTime.alchemicalWizardry.common.items.EnergySword; import WayofTime.alchemicalWizardry.common.items.armour.BoundArmour; import WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour; import WayofTime.alchemicalWizardry.common.omega.OmegaParadigm; @@ -66,7 +68,28 @@ public class AlchemicalWizardryEventHooks public static Map> respawnMap = new HashMap(); public static Map> forceSpawnMap = new HashMap(); - + @SubscribeEvent + public void onEntityInteractEvent(EntityInteractEvent event) + { + EntityPlayer player = event.entityPlayer; + OmegaParadigm parad = OmegaRegistry.getOmegaParadigmOfWeilder(player); + if(parad == null) + { + return; + } + ItemStack heldItem = player.getHeldItem(); + if(heldItem == null) + { + parad.onEmptyHandEntityInteract(player, event.target); + }else + { + if(heldItem.getItem() instanceof EnergySword) + { + parad.onBoundSwordInteractWithEntity(player, event.target); + } + } + } + @SubscribeEvent public void onAnvilUpdateEvent(AnvilUpdateEvent event) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/book/BookParser.java b/src/main/java/WayofTime/alchemicalWizardry/common/book/BookParser.java index cc15f601..203b765a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/book/BookParser.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/book/BookParser.java @@ -7,7 +7,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -211,25 +210,25 @@ public class BookParser iEntryList.clear(); // - File bmDirectory = new File("src/main/resources/assets/alchemicalwizardryBooks"); - if(!bmDirectory.exists()) - { - bmDirectory.mkdirs(); - } - - File file = new File(bmDirectory, "books.txt"); -// if (file.exists() && file.length() > 3L) +// File bmDirectory = new File("src/main/resources/assets/alchemicalwizardryBooks"); +// if(!bmDirectory.exists()) +// { +// bmDirectory.mkdirs(); +// } +// +// File file = new File(bmDirectory, "books.txt"); +//// if (file.exists() && file.length() > 3L) +//// { +//// +//// }else // { -// -// }else - { - PrintWriter writer = new PrintWriter(file); - for(String stri : strings) - { - writer.println(stri); - } - writer.close(); - } +// PrintWriter writer = new PrintWriter(file); +// for(String stri : strings) +// { +// writer.println(stri); +// } +// writer.close(); +// } // } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java index dd69f232..7822f86d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java @@ -1,8 +1,7 @@ package WayofTime.alchemicalWizardry.common.items; -import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -18,8 +17,11 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; - -import java.util.List; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.omega.OmegaParadigm; +import WayofTime.alchemicalWizardry.common.omega.OmegaRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EnergySword extends ItemSword { @@ -75,11 +77,29 @@ public class EnergySword extends ItemSword return this.passiveIcon; } } + + private OmegaParadigm getOmegaParadigmOfWeilder(EntityPlayer player) + { + return OmegaRegistry.getOmegaParadigmOfWeilder(player); + } @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - return !getActivated(stack); + boolean isActive = getActivated(stack); + if(isActive && !player.worldObj.isRemote) + { + OmegaParadigm parad = this.getOmegaParadigmOfWeilder(player); + + if(parad != null && parad.isPlayerWearingFullSet(player)) + { + if(!parad.onBoundSwordLeftClickEntity(stack, player, entity)) + { + return true; + } + } + } + return !isActive; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java index 98c37478..9ab2478a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java @@ -9,6 +9,7 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.common.omega.OmegaParadigm; @@ -19,6 +20,10 @@ public abstract class OmegaArmour extends BoundArmour { public OmegaParadigm paradigm; public Reagent reagent; + protected boolean storeBiomeID = false; + protected boolean storeDimensionID = false; + protected boolean storeYLevel = false; + protected boolean storeSeesSky = false; public OmegaArmour(int armorType) { @@ -30,6 +35,11 @@ public abstract class OmegaArmour extends BoundArmour this.paradigm = paradigm; } + public OmegaParadigm getOmegaParadigm() + { + return this.paradigm; + } + public void setReagent(Reagent reagent) { this.reagent = reagent; @@ -40,6 +50,28 @@ public abstract class OmegaArmour extends BoundArmour { super.onArmorTick(world, player, itemStack); + if(this.storeBiomeID()) + { + int xCoord = (int) Math.floor(player.posX); + int zCoord = (int) Math.floor(player.posZ); + + BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord); + if(biome != null) + { + this.setBiomeIDStored(itemStack, biome.biomeID); + } + } + + if(this.storeDimensionID()) + { + this.setDimensionIDStored(itemStack, world.provider.dimensionId); + } + + if(this.storeYLevel()) + { + this.setYLevelStored(itemStack, (int) Math.floor(player.posY)); + } + if(this.armorType == 1) { paradigm.onUpdate(world, player, itemStack); @@ -222,4 +254,96 @@ public abstract class OmegaArmour extends BoundArmour { return this.getOmegaStallingDuration(stack) > 0; } + + public boolean storeBiomeID() + { + return this.storeBiomeID; + } + + public boolean storeDimensionID() + { + return this.storeDimensionID; + } + + public boolean storeYLevel() + { + return this.storeYLevel; + } + + public boolean storeSeesSky() + { + return this.storeSeesSky; + } + + public int getBiomeIDStored(ItemStack stack) + { + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) + { + tag = new NBTTagCompound(); + stack.setTagCompound(tag); + } + + return tag.getInteger("biomeID"); + } + + public void setBiomeIDStored(ItemStack stack, int id) + { + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) + { + tag = new NBTTagCompound(); + stack.setTagCompound(tag); + } + + tag.setInteger("biomeID", id); + } + + public int getDimensionIDStored(ItemStack stack) + { + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) + { + tag = new NBTTagCompound(); + stack.setTagCompound(tag); + } + + return tag.getInteger("dimensionID"); + } + + public void setDimensionIDStored(ItemStack stack, int id) + { + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) + { + tag = new NBTTagCompound(); + stack.setTagCompound(tag); + } + + tag.setInteger("dimensionID", id); + } + + public int getYLevelStored(ItemStack stack) + { + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) + { + tag = new NBTTagCompound(); + stack.setTagCompound(tag); + } + + return tag.getInteger("yLevel"); + } + + public void setYLevelStored(ItemStack stack, int level) + { + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) + { + tag = new NBTTagCompound(); + stack.setTagCompound(tag); + } + + tag.setInteger("yLevel", level); + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java index 4d1bf755..b4e62634 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java @@ -1,10 +1,18 @@ package WayofTime.alchemicalWizardry.common.items.armour; +import java.util.UUID; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; import WayofTime.alchemicalWizardry.common.renderer.model.ModelOmegaWater; public class OmegaArmourWater extends OmegaArmour @@ -12,6 +20,7 @@ public class OmegaArmourWater extends OmegaArmour public OmegaArmourWater(int armorType) { super(armorType); + this.storeBiomeID = true; } @Override @@ -33,4 +42,53 @@ public class OmegaArmourWater extends OmegaArmour { return new ModelOmegaWater(0.5f, false, false, true, false); } + + @Override + public Multimap getAttributeModifiers(ItemStack stack) + { + Multimap map = HashMultimap.create(); + int biomeID = this.getBiomeIDStored(stack); + BiomeGenBase biome = BiomeGenBase.getBiome(biomeID); + if(biome != null) + { + map.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(85312 /** Random number **/, armorType), "Armor modifier" + armorType, getDefaultHealthBoost()*getHealthBoostModifierForBiome(biome), 0)); + } + return map; + } + + public float getDefaultHealthBoost() + { + switch(this.armorType) + { + case 0: + return 2.5f; + case 1: + return 4; + case 2: + return 3.5f; + case 3: + return 2; + } + return 0.25f; + } + + public float getHealthBoostModifierForBiome(BiomeGenBase biome) + { + if(biome.isEqualTo(BiomeGenBase.hell)) + { + return -0.5f; + } + + if(biome.isEqualTo(BiomeGenBase.ocean)) + { + return 2.0f; + } + + if(biome.isHighHumidity()) + { + return 1.5f; + } + + return 0.5f; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java index 6c7e72d7..375c1be8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java @@ -1,9 +1,17 @@ package WayofTime.alchemicalWizardry.common.items.armour; +import java.util.UUID; + import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.item.ItemStack; import WayofTime.alchemicalWizardry.common.renderer.model.ModelOmegaWind; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,6 +20,7 @@ public class OmegaArmourWind extends OmegaArmour public OmegaArmourWind(int armorType) { super(armorType); + this.storeYLevel = true; } @Override @@ -33,4 +42,36 @@ public class OmegaArmourWind extends OmegaArmour { return new ModelOmegaWind(0.5f, false, false, true, false); } + + @Override + public Multimap getAttributeModifiers(ItemStack stack) + { + Multimap map = HashMultimap.create(); + int yLevel = this.getYLevelStored(stack); + + map.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(85212 /** Random number **/, armorType), "Armor modifier" + armorType, getDefaultHealthBoost()*getHealthBoostModifierForLevel(yLevel), 0)); + + return map; + } + + public float getDefaultHealthBoost() + { + switch(this.armorType) + { + case 0: + return 2.5f; + case 1: + return 4; + case 2: + return 3.5f; + case 3: + return 2; + } + return 0.25f; + } + + public float getHealthBoostModifierForLevel(int yLevel) + { + return (float)Math.sqrt(((float)yLevel)/64f) * 1.5f - 1; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java index a8ca81dc..e21cddbe 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java @@ -133,4 +133,26 @@ public class OmegaParadigm { return false; } + + /** + * + * @param stack + * @param player + * @param entity + * @return False if it does not do damage + */ + public boolean onBoundSwordLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + return true; + } + + public void onEmptyHandEntityInteract(EntityPlayer player, Entity entity) + { + + } + + public void onBoundSwordInteractWithEntity(EntityPlayer player, Entity entity) + { + + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java index b4d9dedc..d8106b55 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java @@ -2,7 +2,10 @@ package WayofTime.alchemicalWizardry.common.omega; import java.util.HashMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; +import WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour; public class OmegaRegistry { @@ -22,4 +25,18 @@ public class OmegaRegistry { return omegaList.containsKey(reagent); } + + public static OmegaParadigm getOmegaParadigmOfWeilder(EntityPlayer player) + { + ItemStack[] armours = player.inventory.armorInventory; + + ItemStack chestStack = armours[2]; + + if(chestStack != null && chestStack.getItem() instanceof OmegaArmour) + { + return ((OmegaArmour)chestStack.getItem()).getOmegaParadigm(); + } + + return null; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java index 973b7199..8d5539e0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java @@ -43,7 +43,7 @@ public class RitualEffectOmegaTest extends RitualEffect for(EntityPlayer player : playerList) { - Reagent reagent = ReagentRegistry.aquasalusReagent; + Reagent reagent = ReagentRegistry.aetherReagent; OmegaParadigm waterParadigm = OmegaRegistry.getParadigmForReagent(reagent); waterParadigm.convertPlayerArmour(player);