diff options
Diffstat (limited to 'src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java')
| -rw-r--r-- | src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java b/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java index a6ea354..fa47e3e 100644 --- a/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java +++ b/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java @@ -1,19 +1,18 @@ package gmail.Lance5057.modifiers; +import java.util.ArrayList; import java.util.Random; -import mods.battlegear2.api.PlayerEventChild; import mods.battlegear2.api.core.IBattlePlayer; -import mods.battlegear2.api.core.InventoryPlayerBattle; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; import net.minecraft.world.World; -import net.minecraftforge.event.entity.player.PlayerEvent; import tconstruct.library.ActiveToolMod; import tconstruct.library.tools.ToolCore; @@ -21,17 +20,39 @@ public class TDefenseActiveToolMod extends ActiveToolMod { @Override public void updateTool(ToolCore tool, ItemStack stack, World world, Entity entity) { -// NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); -// -// if (!tags.hasKey("Broken")) { -// if(((IBattlePlayer)entity).isBlockingWithShield()) -// { -// if(ShieldEvent.source.getEntity() instanceof EntityFireball) -// { -// -// } -// } -// } + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + + if (!tags.getBoolean("Broken")) + { + //stack.getTagCompound().getCompoundTag("InfiTool").setInteger("RenderHead", 100); + if(((IBattlePlayer)entity).isBlockingWithShield()) + { + if(tags.hasKey("Crest of Mirrors")) + { + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(((EntityLivingBase)entity).posX - 3, ((EntityLivingBase)entity).posY - 3, ((EntityLivingBase)entity).posZ - 3, ((EntityLivingBase)entity).posX + 3, ((EntityLivingBase)entity).posY + 3, ((EntityLivingBase)entity).posZ + 3); + + ArrayList<EntityFireball> fireballs = (ArrayList<EntityFireball>) world.getEntitiesWithinAABB(EntityFireball.class, boundingBox); + for (EntityFireball fireball : fireballs) + { + if (fireball.getDistanceSqToEntity(((EntityLivingBase)entity)) <= 25) + { + Vec3 playerlook = ((EntityLivingBase)entity).getLookVec(); + + fireball.motionX = playerlook.xCoord; + fireball.motionY = playerlook.yCoord; + fireball.motionZ = playerlook.zCoord; + fireball.accelerationX = fireball.motionX * 0.1D; + fireball.accelerationY = fireball.motionY * 0.1D; + fireball.accelerationZ = fireball.motionZ * 0.1D; + + fireball.shootingEntity = ((EntityLivingBase)entity); + + ((EntityLivingBase)entity).worldObj.playSoundAtEntity(((EntityLivingBase)entity), "battlegear2:shield", 1, 1); + } + } + } + } + } } @Override |
