public EntityNeedle(World world, EntityPlayer owner, ItemStack ammoSource, float spread) {
    this(world);
    if (owner != null) _owner = owner.getCommandSenderName();
    _ammoSource = ammoSource;

    this.setLocationAndAngles(
        owner.posX,
        owner.posY + owner.getEyeHeight(),
        owner.posZ,
        owner.rotationYaw,
        owner.rotationPitch);
    this.posX -= (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
    this.posY -= 0.1D;
    this.posZ -= (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.yOffset = 0.0F;
    this.motionX =
        (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
            * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
    this.motionZ =
        (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
            * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
    this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
    this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.25F, spread);
    this.distance = 0;
  }
 @Override
 public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
   if (toolMaterial == ToolMaterial.EMERALD) {
     if (player.getHeldItem() != null && ZSSPlayerInfo.get(player).canBlock()) {
       Vec3 vec3 = player.getLookVec();
       double dx = player.posX + vec3.xCoord * 2.0D;
       double dy = player.posY + player.getEyeHeight() + vec3.yCoord * 2.0D;
       double dz = player.posZ + vec3.zCoord * 2.0D;
       List<EntityFireball> list =
           player.worldObj.getEntitiesWithinAABB(
               EntityFireball.class,
               AxisAlignedBB.getBoundingBox(dx - 1, dy - 1, dz - 1, dx + 1, dy + 1, dz + 1));
       for (EntityFireball fireball : list) {
         DamageSource source = DamageSource.causeFireballDamage(fireball, fireball.shootingEntity);
         if (canBlockDamage(stack, source)
             && fireball.attackEntityFrom(DamageSource.causePlayerDamage(player), 1.0F)) {
           fireball.getEntityData().setBoolean("isReflected", true);
           ZSSPlayerInfo.get(player).onAttackBlocked(stack, 1.0F);
           WorldUtils.playSoundAtEntity(player, Sounds.HAMMER, 0.4F, 0.5F);
           break;
         }
       }
     }
   }
 }
Exemple #3
0
 /**
  * Copied from CoFHLib BlockHelper.class
  * (https://github.com/CoFH/CoFHLib/blob/master/src/main/java/cofh/util/BlockHelper.java), with
  * KingLemmings permission!
  *
  * @author King Lemming
  */
 public static MovingObjectPosition getMovingObjectPosition(EntityPlayer player) {
   Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
   Vec3 lookVec = player.getLook(1);
   posVec.yCoord += player.getEyeHeight();
   lookVec = posVec.addVector(lookVec.xCoord * 4.5F, lookVec.yCoord * 4.5F, lookVec.zCoord * 4.5F);
   return player.worldObj.rayTraceBlocks(posVec, lookVec);
 }
  @Override
  public void onUsingTick(ItemStack is, EntityPlayer ep, int count) {
    if (is.getItemDamage() > 0 && this.getWater(is) > 0) {
      double r = 1;
      double d = ReikaRandomHelper.getRandomPlusMinus(2.5, 2);
      Vec3 vec = ep.getLookVec();
      double dx = ep.posX + vec.xCoord * d;
      double dy = ep.posY + ep.getEyeHeight() + vec.yCoord * d;
      double dz = ep.posZ + vec.zCoord * d;
      if (count % TICK_PER_KJ == 0) {
        AxisAlignedBB box = AxisAlignedBB.getBoundingBox(dx, dy, dz, dx, dy, dz).expand(r, r, r);
        List<EntityRadiation> li = ep.worldObj.getEntitiesWithinAABB(EntityRadiation.class, box);
        for (EntityRadiation e : li) {
          e.clean();
        }
      }
      int n = ReikaRandomHelper.getRandomPlusMinus(8, 4);
      for (int i = 0; i < n; i++) {
        double v = ReikaRandomHelper.getRandomPlusMinus(0.1875, 0.0625);
        double vx = vec.xCoord * v;
        double vy = vec.yCoord * v;
        double vz = vec.zCoord * v;

        vx = ReikaRandomHelper.getRandomPlusMinus(vx, 0.001);
        vz = ReikaRandomHelper.getRandomPlusMinus(vz, 0.001);

        ReikaParticleHelper.RAIN.spawnAt(ep.worldObj, dx, dy, dz, vx, vy, vz);
      }
    }
  }
  /**
   * Returns the MovingObjectPosition of block hit by player. Adapted from protected method of same
   * name in Item.class.
   */
  private MovingObjectPosition getMovingObjectPositionFromPlayer(
      World world, EntityPlayer entityPlayer) {
    double xPos = entityPlayer.prevPosX + (entityPlayer.posX - entityPlayer.prevPosX);
    double yPos =
        entityPlayer.prevPosY
            + (entityPlayer.posY - entityPlayer.prevPosY)
            + (world.isRemote
                ? entityPlayer.getEyeHeight() - entityPlayer.getDefaultEyeHeight()
                : entityPlayer.getEyeHeight());
    double zPos = entityPlayer.prevPosZ + (entityPlayer.posZ - entityPlayer.prevPosZ);

    float pitch =
        entityPlayer.prevRotationPitch
            + (entityPlayer.rotationPitch - entityPlayer.prevRotationPitch);
    float yaw =
        entityPlayer.prevRotationYaw + (entityPlayer.rotationYaw - entityPlayer.prevRotationYaw);

    float commonComp = -MathHelper.cos(-pitch * 0.017453292F);

    float xComp = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI) * commonComp;
    float yComp = MathHelper.sin(-pitch * 0.017453292F);
    float zComp = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI) * commonComp;
    double reachDist = 5.0D;

    if (entityPlayer instanceof EntityPlayerMP) {
      reachDist = ((EntityPlayerMP) entityPlayer).theItemInWorldManager.getBlockReachDistance();
    }

    Vec3 vec1 = Vec3.createVectorHelper(xPos, yPos, zPos);
    Vec3 vec2 = vec1.addVector(xComp * reachDist, yComp * reachDist, zComp * reachDist);

    return world.rayTraceBlocks(vec1, vec2);
  }
Exemple #6
0
  @Override
  public void doSpacialAttack(ItemStack stack, EntityPlayer player) {
    World world = player.worldObj;

    NBTTagCompound tag = ItemSlashBlade.getItemTagCompound(stack);

    player.worldObj.playSoundAtEntity(player, "mob.blaze.hit", 0.2F, 0.6F);

    if (!world.isRemote) {

      final int cost = -20;
      if (!ItemSlashBlade.ProudSoul.tryAdd(tag, cost, false)) {
        stack.damageItem(10, player);
      }

      ItemSlashBlade blade = (ItemSlashBlade) stack.getItem();

      {
        AxisAlignedBB bb = player.getEntityBoundingBox();
        bb = bb.expand(5.0f, 0.25f, 5.0f);

        List<Entity> list =
            world.getEntitiesInAABBexcluding(player, bb, EntitySelectorAttackable.getInstance());

        for (Entity curEntity : list) {
          StylishRankManager.setNextAttackType(player, StylishRankManager.AttackTypes.CircleSlash);
          blade.attackTargetEntity(stack, curEntity, player, true);
          player.onCriticalHit(curEntity);
        }
      }

      float baseModif = blade.getBaseAttackModifiers(tag);
      int level =
          Math.max(1, EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack));
      float magicDamage = (baseModif / 2.0f);

      int rank = StylishRankManager.getStylishRank(player);
      if (5 <= rank)
        magicDamage += ItemSlashBlade.AttackAmplifier.get(tag) * (0.25f + (level / 5.0f));

      for (int i = 0; i < 6; i++) {
        EntityDrive entityDrive = new EntityDrive(world, player, magicDamage, false, 0);
        entityDrive.setLocationAndAngles(
            player.posX,
            player.posY + (double) player.getEyeHeight() / 2D,
            player.posZ,
            player.rotationYaw + 60 * i /*+ (entityDrive.getRand().nextFloat() - 0.5f) * 60*/,
            0); // (entityDrive.getRand().nextFloat() - 0.5f) * 60);
        entityDrive.setDriveVector(0.5f);
        entityDrive.setLifeTime(10);
        entityDrive.setIsMultiHit(false);
        entityDrive.setRoll(90.0f /*+ 120 * (entityDrive.getRand().nextFloat() - 0.5f)*/);
        if (entityDrive != null) {
          world.spawnEntityInWorld(entityDrive);
        }
      }
    }

    ItemSlashBlade.setComboSequence(tag, ItemSlashBlade.ComboSequence.Battou);
  }
Exemple #7
0
 // serverとclientで視点補正がかかっていたりいなかったりするため、その差を吸収する
 // see: http://forum.minecraftuser.jp/viewtopic.php?f=21&t=7907#p63907
 public static Vec3 getPlayerPosition(EntityPlayer player) {
   Vec3 pos = player.getPosition(1.0F);
   if (player.yOffset == 0.0) {
     pos.yCoord += player.getEyeHeight();
   }
   return pos;
 }
  /**
   * Creates a MovingObjectPosition based on where a player is looking.
   *
   * @param player: The player to get the looking position of.
   * @param length: The distance to go outwards from the player, the maximum "reach". Default reach
   *     is 4.5D.
   * @return MovingObjectPosition: A MovingObjectPosition containing the exact location where the
   *     player is looking.
   */
  public static RayTraceResult rayTrace(EntityPlayer player, double length) {

    final Vec3d vec1 = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
    final Vec3d vec2 = player.getLookVec();
    final Vec3d vec3 =
        vec1.addVector(vec2.xCoord * length, vec2.yCoord * length, vec2.zCoord * length);
    return player.worldObj.rayTraceBlocks(vec1, vec3);
  }
 private boolean checkPlayerWater(EntityPlayer thePlayer) {
   if (thePlayer.isInWater()) {
     int x = MathHelper.floor_double(thePlayer.posX + 0.5D);
     int y = MathHelper.floor_double(thePlayer.posY + thePlayer.getEyeHeight());
     int z = MathHelper.floor_double(thePlayer.posZ + 0.5D);
     return thePlayer.worldObj.getBlock(x, y, z).getMaterial() == Material.water;
   }
   return false;
 }
Exemple #10
0
  public static MovingObjectPosition getCurrentMovingObjectPosition(
      EntityPlayer player, double distance, boolean fluid) {

    Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
    Vec3 lookVec = player.getLook(1);
    posVec.yCoord += player.getEyeHeight();
    lookVec =
        posVec.addVector(
            lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance);
    return player.worldObj.rayTraceBlocks(posVec, lookVec, fluid);
  }
 @Override
 @SideOnly(Side.CLIENT)
 public final int getRenderColor(int dmg) {
   // return Color.HSBtoRGB(((System.currentTimeMillis()/60)%360)/360F, 0.8F, 1);
   World world = Minecraft.getMinecraft().theWorld;
   EntityPlayer ep = Minecraft.getMinecraft().thePlayer;
   int x = MathHelper.floor_double(ep.posX);
   int y = MathHelper.floor_double(ep.posY + ep.getEyeHeight());
   int z = MathHelper.floor_double(ep.posZ);
   return this.colorMultiplier(world, x, y, z);
 }
  @Override
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    PropertyDoom doom = PropertyDoom.get(par3EntityPlayer);

    Vec3 vec = WorldHelper.getVecFromEntity(par3EntityPlayer);
    if (vec == null) return par1ItemStack;

    if (doom != null && !par2World.isRemote && getStackCooldown(par1ItemStack) == 0) {
      double d4 = vec.xCoord - par3EntityPlayer.posX;
      double d5 = vec.yCoord - (par3EntityPlayer.posY + par3EntityPlayer.height / 2.0F);
      double d6 = vec.zCoord - par3EntityPlayer.posZ;

      if (!par3EntityPlayer.isSneaking()) {
        if (canUseAbility(doom, TragicConfig.doomAbilityCost[35]) && TragicConfig.doomAbility[35]) {
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[35]);
          setStackCooldown(par1ItemStack, 5);

          EntityWitherSkull skull = new EntityWitherSkull(par2World, par3EntityPlayer, d4, d5, d6);
          skull.posY += par3EntityPlayer.getEyeHeight();
          par2World.spawnEntityInWorld(skull);
          return par1ItemStack;
        }
      } else {
        if (canUseAbility(doom, TragicConfig.doomAbilityCost[36]) && TragicConfig.doomAbility[36]) {
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[36]);
          setStackCooldown(par1ItemStack, 5);

          EntityWitherSkull skull = new EntityWitherSkull(par2World, par3EntityPlayer, d4, d5, d6);
          skull.posY += par3EntityPlayer.getEyeHeight();
          skull.setInvulnerable(true);
          par2World.spawnEntityInWorld(skull);
          return par1ItemStack;
        }
      }
    }

    return par1ItemStack;
  }
 @SubscribeEvent
 public void onPlayerTick(TickEvent.PlayerTickEvent event) {
   if (event.side.isClient()
       && event.phase == TickEvent.Phase.START
       && event.player != null
       && event.player == ClientUtils.mc().renderViewEntity) {
     skyhookGrabableConnections.clear();
     EntityPlayer player = event.player;
     ItemStack stack = player.getCurrentEquippedItem();
     if (stack != null && stack.getItem() instanceof ItemSkyhook) {
       TileEntity connector = null;
       double lastDist = 0;
       Connection line = null;
       double py = player.posY + player.getEyeHeight();
       for (int xx = -2; xx <= 2; xx++)
         for (int zz = -2; zz <= 2; zz++)
           for (int yy = 0; yy <= 3; yy++) {
             TileEntity tile =
                 player.worldObj.getTileEntity(
                     (int) player.posX + xx, (int) py + yy, (int) player.posZ + zz);
             if (tile != null) {
               Connection con =
                   SkylineHelper.getTargetConnection(
                       player.worldObj, tile.xCoord, tile.yCoord, tile.zCoord, player, null);
               if (con != null) {
                 double d = tile.getDistanceFrom(player.posX, py, player.posZ);
                 if (connector == null || d < lastDist) {
                   connector = tile;
                   lastDist = d;
                   line = con;
                 }
               }
             }
           }
       if (line != null && connector != null) skyhookGrabableConnections.add(line);
     }
   }
   if (event.side.isClient() && event.phase == TickEvent.Phase.END && event.player != null) {
     EntityPlayer player = event.player;
     ItemStack stack = player.getCurrentEquippedItem();
     if (stack != null
         && stack.getItem() instanceof ItemDrill
         && (player != ClientUtils.mc().renderViewEntity
             || ClientUtils.mc().gameSettings.thirdPersonView != 0)) {
       if (player.getItemInUseCount() <= 0) {
         player.clearItemInUse();
         player.setItemInUse(stack, 2147483647);
       }
     }
   }
 }
 private boolean isPlayerLookingAtTarget() {
   // code used from the Enderman player looking code.
   EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
   World world = FMLClientHandler.instance().getClient().theWorld;
   Vec3 vec3 = player.getLook(1.0F).normalize();
   Vec3 vec31 =
       Vec3.createVectorHelper(
           entity.posX - player.posX,
           entity.boundingBox.minY + entity.height / 2.0F - (player.posY + player.getEyeHeight()),
           entity.posZ - player.posZ);
   double d0 = vec31.lengthVector();
   vec31 = vec31.normalize();
   double d1 = vec3.dotProduct(vec31);
   return d1 > 1.0D - 0.050D / d0;
 }
 protected void superSmash(ItemStack itemstack, World world, EntityPlayer entityplayer) {
   entityplayer.swingItem();
   float f = getEntityDamage() / 2F;
   WarhammerExplosion expl =
       new WarhammerExplosion(
           world,
           entityplayer,
           entityplayer.posX,
           entityplayer.posY - entityplayer.getEyeHeight(),
           entityplayer.posZ,
           f);
   expl.doEntityExplosion(DamageSource.causePlayerDamage(entityplayer));
   expl.doParticleExplosion(true, false);
   itemstack.damageItem(16, entityplayer);
   entityplayer.addExhaustion(6F);
   setSmashed(entityplayer);
 }
 public void onPlayerStoppedUsing(
     ItemStack par1ItemStack, World world, EntityPlayer entityplayer, int par4) {
   par1ItemStack.damageItem(27, entityplayer);
   entityplayer.addExhaustion(5.0F);
   world.playSoundAtEntity(
       entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
   if (!world.isRemote) {
     Vec3 look = entityplayer.getLookVec();
     EntityWitherSkull fireball2 = new EntityWitherSkull(world, entityplayer, 1.0D, 1.0D, 1.0D);
     fireball2.setPosition(
         entityplayer.posX + look.xCoord * 1.0D,
         entityplayer.posY
             + look.yCoord
             + (double) entityplayer.getEyeHeight()
             - 0.10000000149011612D,
         entityplayer.posZ + look.zCoord * 1.0D);
     fireball2.accelerationX = look.xCoord * 0.1D;
     fireball2.accelerationY = look.yCoord * 0.1D;
     fireball2.accelerationZ = look.zCoord * 0.1D;
     world.spawnEntityInWorld(fireball2);
   }
 }
 public RotatingBase(World world, EntityPlayer entityliving, float f, float f1) {
   this(world);
   owner = entityliving;
   setLocationAndAngles(
       entityliving.posX,
       entityliving.posY + (double) entityliving.getEyeHeight(),
       entityliving.posZ,
       entityliving.rotationYaw,
       entityliving.rotationPitch);
   posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
   posY -= 0.10000000149011612D;
   posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
   setPosition(posX, posY, posZ);
   yOffset = 0.0F;
   motionX =
       -MathHelper.sin((rotationYaw / 180F) * 3.141593F)
           * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
   motionZ =
       MathHelper.cos((rotationYaw / 180F) * 3.141593F)
           * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
   motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
   setArrowHeading(motionX, motionY, motionZ, f, f1);
 }
  @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<Entity> 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++;
          }
        }
      }
    }
  }
    /**
     * Checks to see if this enderman should be attacking this player
     */
    private boolean shouldAttackPlayer(EntityPlayer p_70821_1_)
    {

        Vec3 vec3 = p_70821_1_.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - p_70821_1_.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (p_70821_1_.posY + (double)p_70821_1_.getEyeHeight()), this.posZ - p_70821_1_.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? p_70821_1_.canEntityBeSeen(this) : false;
        
    }
  @Override
  public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer ep) {
    if (is.getItemDamage() <= 0) {
      this.noCharge();
      return is;
    }
    this.warnCharge(is);
    if (!ReikaPlayerAPI.playerHasOrIsCreative(ep, Block.gravel.blockID, -1)) {
      if (!world.isRemote) world.playAuxSFX(1001, (int) ep.posX, (int) ep.posY, (int) ep.posZ, 1);
      return is;
    }
    for (float i = 1; i <= 128; i += 0.5) {
      Vec3 look = ep.getLookVec();
      double[] looks = ReikaVectorHelper.getPlayerLookCoords(ep, i);
      AxisAlignedBB fov =
          AxisAlignedBB.getBoundingBox(
              looks[0] - 0.5,
              looks[1] - 0.5,
              looks[2] - 0.5,
              looks[0] + 0.5,
              looks[1] + 0.5,
              looks[2] + 0.5);
      List infov = world.getEntitiesWithinAABB(EntityLivingBase.class, fov);
      for (int k = 0; k < infov.size(); k++) {
        EntityLivingBase ent = (EntityLivingBase) infov.get(k);
        if (!ep.equals(ent)
            && this.isEntityAttackable(ent)
            && ReikaWorldHelper.lineOfSight(world, ep, ent)) {
          double dist =
              ReikaMathLibrary.py3d(ep.posX - ent.posX, ep.posY - ent.posY, ep.posZ - ent.posZ);
          double x = ep.posX + look.xCoord;
          double y = ep.posY + ep.getEyeHeight() + look.yCoord;
          double z = ep.posZ + look.zCoord;
          double dx = ent.posX - ep.posX;
          double dy = ent.posY - ep.posY;
          double dz = ent.posZ - ep.posZ;
          if (!world.isRemote) {
            ItemStack fl = new ItemStack(Item.flint);
            EntityItem ei =
                new EntityItem(
                    world,
                    look.xCoord / look.lengthVector() + ep.posX,
                    look.yCoord / look.lengthVector() + ep.posY,
                    look.zCoord / look.lengthVector() + ep.posZ,
                    fl);
            ei.delayBeforeCanPickup = 100;
            ei.motionX = dx;
            ei.motionY = dy + 1;
            ei.motionZ = dz;
            // ReikaChatHelper.writeCoords(world, ei.posX, ei.posY, ei.posZ);
            ei.velocityChanged = true;
            world.playSoundAtEntity(ep, "dig.gravel", 1.5F, 2F);
            ei.lifespan = 5;
            world.spawnEntityInWorld(ei);

            if (is.getItemDamage() > 4096) { // approx the 1-hit kill of a 10-heart mob
              // ReikaPacketHelper.sendUpdatePacket(RotaryCraft.packetChannel,
              // PacketRegistry.GRAVELGUN.getMinValue(), world, (int)ent.posX, (int)ent.posY,
              // (int)ent.posZ);
              // world.playSoundAtEntity(ep, "random.explode", 0.25F, 1F);
            }
            if (ent instanceof EntityDragon) {
              EntityDragon ed = (EntityDragon) ent;
              ed.attackEntityFromPart(
                  ed.dragonPartBody, DamageSource.causePlayerDamage(ep), this.getAttackDamage(is));
            } else {
              int dmg = this.getAttackDamage(is);
              if (ent instanceof EntityPlayer) {
                for (int n = 1; n < 5; n++) {
                  ItemRegistry ir = ItemRegistry.getEntry(ent.getCurrentItemOrArmor(n));
                  if (ir != null) {
                    if (ir.isBedrockArmor()) dmg *= 0.75;
                  }
                }
              }
              ent.attackEntityFrom(DamageSource.causePlayerDamage(ep), dmg);
              if (dmg >= 500) RotaryAchievements.MASSIVEHIT.triggerAchievement(ep);
            }
            if (ent instanceof EntityMob
                && (ent.isDead || ent.getHealth() <= 0)
                && ReikaMathLibrary.py3d(ep.posX - ent.posX, ep.posY - ent.posY, ep.posZ - ent.posZ)
                    >= 80) RotaryAchievements.GRAVELGUN.triggerAchievement(ep);
          }
          // ReikaWorldHelper.spawnParticleLine(world, x, y, z, ent.posX, ent.posY+ent.height/2,
          // ent.posZ, "crit", 0, 0, 0, 60);
          for (float t = 0; t < 2; t += 0.05F)
            world.spawnParticle("crit", x, y, z, dx / dist * t, dy / dist * t, dz / dist * t);
        }
      }
      if (infov.size() > 0 && !(infov.size() == 1 && infov.get(0) instanceof EntityPlayer)) {
        if (!ep.capabilities.isCreativeMode)
          ReikaInventoryHelper.findAndDecrStack(
              Block.gravel.blockID, -1, ep.inventory.mainInventory);
        return new ItemStack(is.itemID, is.stackSize, is.getItemDamage() - 1);
      }
    }
    return is;
  }
  @Override
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    PropertyDoom doom = PropertyDoom.get(par3EntityPlayer);

    if (!par3EntityPlayer.isSneaking()
        || !TragicWeapon.canUseAbility(doom, TragicConfig.doomAbilityCost[5])) {
      ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
      MinecraftForge.EVENT_BUS.post(event);
      if (event.isCanceled()) return event.result;

      if (par3EntityPlayer.capabilities.isCreativeMode
          || par3EntityPlayer.inventory.hasItem(Items.arrow)) {
        par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
      }
    } else {
      if (TragicWeapon.getStackCooldown(par1ItemStack) == 0 && TragicConfig.doomAbility[8]) {
        float f = 1.0F;
        float f1 =
            par3EntityPlayer.prevRotationPitch
                + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f;
        float f2 =
            par3EntityPlayer.prevRotationYaw
                + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f;
        double d0 =
            par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * f;
        double d1 =
            par3EntityPlayer.prevPosY
                + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * f
                + (par3EntityPlayer.worldObj.isRemote
                    ? par3EntityPlayer.getEyeHeight() - par3EntityPlayer.getDefaultEyeHeight()
                    : par3EntityPlayer
                        .getEyeHeight()); // isRemote check to revert changes to ray trace position
        // due to adding the eye height clientside and player
        // yOffset differences
        double d2 =
            par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * f;
        Vec3 vec3 = Vec3.createVectorHelper(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 = 50.0D;

        if (par3EntityPlayer instanceof EntityPlayerMP) {
          d3 =
              ((EntityPlayerMP) par3EntityPlayer).theItemInWorldManager.getBlockReachDistance()
                  + 46.0;
        }

        Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
        MovingObjectPosition mop =
            par3EntityPlayer.worldObj.func_147447_a(vec3, vec31, true, false, true);

        if (mop == null) {
          if (!par2World.isRemote)
            par3EntityPlayer.addChatMessage(new ChatComponentText("Out of range to teleport to!"));
          return par1ItemStack;
        }

        if (mop.typeOfHit == MovingObjectType.BLOCK
            && par3EntityPlayer instanceof EntityPlayerMP
            && ((EntityPlayerMP) par3EntityPlayer)
                .playerNetServerHandler
                .func_147362_b()
                .isChannelOpen()) {
          if (par3EntityPlayer.isRiding()) par3EntityPlayer.mountEntity((Entity) null);

          double d4 = WorldHelper.getXPositionFromSide(mop.sideHit, mop.hitVec.xCoord);
          double d5 = WorldHelper.getYPositionFromSide(mop.sideHit, mop.hitVec.yCoord);
          double d6 = WorldHelper.getZPositionFromSide(mop.sideHit, mop.hitVec.zCoord);

          par3EntityPlayer.setPositionAndUpdate(d4, d5, d6);
          par3EntityPlayer.fallDistance = 0.0F;
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[8]);
          TragicWeapon.setStackCooldown(par1ItemStack, 5);
        }
      }
    }
    return par1ItemStack;
  }