Example #1
0
 @Override
 public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
   if (world.getBlockId(i, j - 1, k) == this.blockID || world.isBlockOpaqueCube(i, j - 1, k)) {
     return AxisAlignedBB.getBoundingBox(i + 0.3, j, k + 0.3, i + 0.7, j + 1, k + 0.7);
   }
   return AxisAlignedBB.getBoundingBox(i, j + 0.4, k, i + 1, j + 0.6, k + 1);
 }
Example #2
0
  public static IInventory getInventoryAt(World world, double d0, double d1, double d2) {
    IInventory iinventory = null;
    int i = MathHelper.floor(d0);
    int j = MathHelper.floor(d1);
    int k = MathHelper.floor(d2);
    if (!world.isLoaded(i, j, k)) return null; // Spigot
    TileEntity tileentity = world.getTileEntity(i, j, k);

    if (tileentity != null && tileentity instanceof IInventory) {
      iinventory = (IInventory) tileentity;
      if (iinventory instanceof TileEntityChest) {
        Block block = world.getType(i, j, k);

        if (block instanceof BlockChest) {
          iinventory = ((BlockChest) block).m(world, i, j, k);
        }
      } else if (iinventory instanceof TileEntityIronChest) {
        isIronChest = true;
        // alkazia fix for iron chest
      }
    }
    if (iinventory == null) {
      List list =
          world.getEntities(
              (Entity) null,
              AxisAlignedBB.a().a(d0, d1, d2, d0 + 1.0D, d1 + 1.0D, d2 + 1.0D),
              IEntitySelector.b);

      if (list != null && list.size() > 0) {
        iinventory = (IInventory) list.get(world.random.nextInt(list.size()));
      }
    }

    return iinventory;
  }
Example #3
0
  @Override
  public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
    int dir = world.getBlockMetadata(i, j, k);

    if (dir == 0) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.85F, i + 1F, j + 1F, k + 1F);
    } else if (dir == 1) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.0F, i + 0.15F, j + 1F, k + 1F);
    } else if (dir == 2) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.00F, i + 1F, j + 1F, k + 0.15F);
    } else if (dir == 3) {
      return AxisAlignedBB.getBoundingBox(i + 0.85F, j + 0F, k + 0.0F, i + 1F, j + 1F, k + 1F);
    }

    return AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 1, k + 1);
  }
Example #4
0
  public void a(
      World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) {
    AxisAlignedBB axisalignedbb1 = this.e(world, i, j, k);

    if (axisalignedbb1 != null && axisalignedbb.a(axisalignedbb1)) {
      arraylist.add(axisalignedbb1);
    }
  }
Example #5
0
  public boolean b(double d1, double d2, double d3) {
    AxisAlignedBB axisalignedbb = z.c(d1, d2, d3);
    List list = l.a(this, axisalignedbb);

    if (list.size() > 0) {
      return false;
    }
    return !l.b(axisalignedbb);
  }
Example #6
0
  public static EntityItem getEntityItemAt(World world, double d0, double d1, double d2) {
    List list =
        world.a(
            EntityItem.class,
            AxisAlignedBB.a().a(d0, d1, d2, d0 + 1.0D, d1 + 1.0D, d2 + 1.0D),
            IEntitySelector.a);

    return list.size() > 0 ? (EntityItem) list.get(0) : null;
  }
Example #7
0
 public AxisAlignedBB e(World world, int i, int j, int k) {
   return AxisAlignedBB.b(
       (double) i + this.minX,
       (double) j + this.minY,
       (double) k + this.minZ,
       (double) i + this.maxX,
       (double) j + this.maxY,
       (double) k + this.maxZ);
 }
Example #8
0
  public AxisAlignedBB a(World world, int i, int j, int k) {
    int l = world.getData(i, j, k) & 7;
    float f = 0.125F;

    return AxisAlignedBB.a()
        .a(
            (double) i + this.minX,
            (double) j + this.minY,
            (double) k + this.minZ,
            (double) i + this.maxX,
            (double) ((float) j + (float) l * f),
            (double) k + this.maxZ);
  }
Example #9
0
  public AxisAlignedBB e(World world, int i, int j, int k) {
    int l = world.getData(i, j, k) & 7;

    return l >= 3
        ? AxisAlignedBB.a()
            .a(
                (double) i + this.minX,
                (double) j + this.minY,
                (double) k + this.minZ,
                (double) i + this.maxX,
                (double) ((float) j + 0.5F),
                (double) k + this.maxZ)
        : null;
  }
Example #10
0
  public void a(double d1, double d2, double d3) {
    p = d1;
    q = d2;
    r = d3;
    float f1 = I / 2.0F;
    float f2 = J;

    z.c(
        d1 - (double) f1,
        (d2 - (double) H) + (double) R,
        d3 - (double) f1,
        d1 + (double) f1,
        (d2 - (double) H) + (double) R + (double) f2,
        d3 + (double) f1);
  }
 /**
  * Checks if the player is on ground.
  *
  * @return true, if the player is on ground
  */
 public boolean isOnGround() {
   if (onGround == null) {
     final double d0 = 0.01D;
     onGround =
         BlockProperties.isOnGround(
             getBlockAccess(),
             minX - d0,
             minY - yOnGround,
             minZ - d0,
             maxX + d0,
             minY + 0.25,
             maxZ + d0);
     if (!onGround) {
       // TODO: Probably check other ids too before doing this ?
       final double d1 = 0.25D;
       final AxisAlignedBB box =
           useBox.b(
               minX - d1,
               minY - getyOnGround() - d1,
               minZ - d1,
               maxX + d1,
               minY + 0.25 + d1,
               maxZ + d1);
       @SuppressWarnings("rawtypes")
       final List list = worldServer.getEntities(entityPlayer, box);
       @SuppressWarnings("rawtypes")
       Iterator iterator = list.iterator();
       while (iterator.hasNext()) {
         final Entity entity = (Entity) iterator.next();
         final EntityType type = entity.getBukkitEntity().getType();
         if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
         final AxisAlignedBB otherBox = entity.boundingBox;
         if (box.a > otherBox.d
             || box.d < otherBox.a
             || box.b > otherBox.e
             || box.e < otherBox.b
             || box.c > otherBox.f
             || box.f < otherBox.c) continue;
         else {
           onGround = true;
           break;
         }
       }
     }
   }
   return onGround;
 }
  @Override
  public void c() {
    c.setGoalTarget(c.getLastDamager());
    b = c.aK();
    if (a) {
      double d0 = f();
      List list =
          c.world.a(
              c.getClass(),
              AxisAlignedBB.a(c.locX, c.locY, c.locZ, c.locX + 1.0D, c.locY + 1.0D, c.locZ + 1.0D)
                  .grow(d0, 10.0D, d0));
      Iterator iterator = list.iterator();

      while (iterator.hasNext()) {
        EntityCreature entitycreature = (EntityCreature) iterator.next();

        if (c != entitycreature
            && entitycreature.getGoalTarget() == null
            && !entitycreature.c(c.getLastDamager())) {
          // CraftBukkit start - call EntityTargetEvent
          org.bukkit.event.entity.EntityTargetLivingEntityEvent event =
              org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(
                  entitycreature,
                  c.getLastDamager(),
                  org.bukkit.event.entity.EntityTargetEvent.TargetReason
                      .TARGET_ATTACKED_NEARBY_ENTITY);
          if (event.isCancelled()) {
            continue;
          }
          entitycreature.setGoalTarget(
              event.getTarget() == null
                  ? null
                  : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget())
                      .getHandle());
          // CraftBukkit end
        }
      }
    }

    super.c();
  }
Example #13
0
  protected void a(EntityLiving entityliving, boolean flag) {
    if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) {
      if (entityliving instanceof EntityWolf) {
        EntityWolf entitywolf = (EntityWolf) entityliving;

        if (entitywolf.isTamed() && this.name.equals(entitywolf.getOwnerName())) {
          return;
        }
      }

      if (!(entityliving instanceof EntityHuman) || this.C()) {
        List list =
            this.world.a(
                EntityWolf.class,
                AxisAlignedBB.b(
                        this.locX,
                        this.locY,
                        this.locZ,
                        this.locX + 1.0D,
                        this.locY + 1.0D,
                        this.locZ + 1.0D)
                    .grow(16.0D, 4.0D, 16.0D));
        Iterator iterator = list.iterator();

        while (iterator.hasNext()) {
          Entity entity = (Entity) iterator.next();
          EntityWolf entitywolf1 = (EntityWolf) entity;

          if (entitywolf1.isTamed()
              && entitywolf1.I() == null
              && this.name.equals(entitywolf1.getOwnerName())
              && (!flag || !entitywolf1.isSitting())) {
            entitywolf1.setSitting(false);
            entitywolf1.setTarget(entityliving);
          }
        }
      }
    }
  }
Example #14
0
 public Entity(World world) {
   this.id = entityCount++;
   this.aH = 1.0D;
   this.aI = false;
   this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
   this.onGround = false;
   this.bd = false;
   this.velocityChanged = false;
   this.bg = true;
   this.dead = false;
   this.height = 0.0F;
   this.length = 0.6F;
   this.width = 1.8F;
   this.bl = 0.0F;
   this.bm = 0.0F;
   this.fallDistance = 0.0F;
   this.b = 1;
   this.br = 0.0F;
   this.bs = 0.0F;
   this.bt = false;
   this.bu = 0.0F;
   this.random = new Random();
   this.ticksLived = 0;
   this.maxFireTicks = 1;
   this.fireTicks = 0;
   this.maxAirTicks = 300;
   this.bA = false;
   this.noDamageTicks = 0;
   this.airTicks = 300;
   this.justCreated = true;
   this.bD = false;
   this.datawatcher = new DataWatcher();
   this.bF = false;
   this.world = world;
   this.setPosition(0.0D, 0.0D, 0.0D);
   this.datawatcher.a(0, Byte.valueOf((byte) 0));
   this.b();
 }
Example #15
0
 @Override
 public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int i, int j, int k) {
   return AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 0.825, k + 1);
 }
  public void w_() {
    super.w_();
    if (this.lifeTicks == 2) {
      this.world.makeSound(
          this.locX,
          this.locY,
          this.locZ,
          "ambient.weather.thunder",
          10000.0F,
          0.8F + this.random.nextFloat() * 0.2F);
      this.world.makeSound(
          this.locX,
          this.locY,
          this.locZ,
          "random.explode",
          2.0F,
          0.5F + this.random.nextFloat() * 0.2F);
    }

    --this.lifeTicks;
    if (this.lifeTicks < 0) {
      if (this.c == 0) {
        this.die();
      } else if (this.lifeTicks < -this.random.nextInt(10)) {
        --this.c;
        this.lifeTicks = 1;
        this.a = this.random.nextLong();
        if (this.world.areChunksLoaded(
            MathHelper.floor(this.locX),
            MathHelper.floor(this.locY),
            MathHelper.floor(this.locZ),
            10)) {
          int i = MathHelper.floor(this.locX);
          int j = MathHelper.floor(this.locY);
          int k = MathHelper.floor(this.locZ);

          if (this.world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(this.world, i, j, k)) {
            this.world.setTypeId(i, j, k, Block.FIRE.id);
          }
        }
      }
    }

    if (this.lifeTicks >= 0) {
      double d0 = 3.0D;
      List list =
          this.world.b(
              (Entity) this,
              AxisAlignedBB.b(
                  this.locX - d0,
                  this.locY - d0,
                  this.locZ - d0,
                  this.locX + d0,
                  this.locY + 6.0D + d0,
                  this.locZ + d0));

      for (int l = 0; l < list.size(); ++l) {
        Entity entity = (Entity) list.get(l);

        entity.a(this);
      }

      this.world.s = 2;
    }
  }
  private void w() {
    long i = System.nanoTime();
    ArrayList arraylist = new ArrayList();
    Iterator iterator = trackerList.keySet().iterator();

    while (iterator.hasNext()) {
      String s = (String) iterator.next();
      int j = ((Integer) trackerList.get(s)).intValue();

      if (j > 0) {
        trackerList.put(s, Integer.valueOf(j - 1));
      } else {
        arraylist.add(s);
      }
    }

    int k;

    for (k = 0; k < arraylist.size(); ++k) {
      trackerList.remove(arraylist.get(k));
    }

    AxisAlignedBB.a();
    Vec3D.a();
    ++this.ticks;

    // CraftBukkit start - only send timeupdates to the people in that world

    ((org.bukkit.craftbukkit.scheduler.CraftScheduler) this.server.getScheduler())
        .mainThreadHeartbeat(this.ticks);

    // Send timeupdates to everyone, it will get the right time from the world the player is in.
    if (this.ticks % 20 == 0) {
      for (k = 0; k < this.serverConfigurationManager.players.size(); ++k) {
        EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k);
        entityplayer.netServerHandler.sendPacket(
            new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time
      }
    }

    for (k = 0; k < this.worlds.size(); ++k) {
      long l = System.nanoTime();
      // if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
      WorldServer worldserver = this.worlds.get(k);

      /* Drop global timeupdates
      if (this.ticks % 20 == 0) {
          this.serverConfigurationManager.a(new Packet4UpdateTime(worldserver.getTime()), worldserver.worldProvider.dimension);
      }
      // CraftBukkit end */

      worldserver.doTick();

      while (true) {
        if (!worldserver.updateLights()) {
          worldserver.tickEntities();
          break;
        }
      }
    }

    // this.g[k][this.ticks % 100] = System.nanoTime() - l; // CraftBukkit
    // } // CraftBukkit

    this.networkListenThread.a();
    this.serverConfigurationManager.tick();

    // CraftBukkit start
    for (k = 0; k < this.worlds.size(); ++k) {
      this.worlds.get(k).tracker.updatePlayers();
    }
    // CraftBukkit end

    for (k = 0; k < this.C.size(); ++k) {
      ((IUpdatePlayerListBox) this.C.get(k)).a();
    }

    try {
      this.b();
    } catch (Exception exception) {
      log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
    }

    this.f[this.ticks % 100] = System.nanoTime() - i;
    this.u[this.ticks % 100] = Packet.n - this.E;
    this.E = Packet.n;
    this.v[this.ticks % 100] = Packet.o - this.F;
    this.F = Packet.o;
    this.w[this.ticks % 100] = Packet.l - this.G;
    this.G = Packet.l;
    this.x[this.ticks % 100] = Packet.m - this.H;
    this.H = Packet.m;
  }
Example #18
0
  public void j_() {
    super.j_();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.lastYaw =
          this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
      this.lastPitch =
          this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
    }

    int i = this.world.getTypeId(this.d, this.e, this.f);

    if (i > 0) {
      Block.byId[i].updateShape(this.world, this.d, this.e, this.f);
      AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.d, this.e, this.f);

      if (axisalignedbb != null
          && axisalignedbb.a(this.world.getVec3DPool().create(this.locX, this.locY, this.locZ))) {
        this.inGround = true;
      }
    }

    if (this.shake > 0) {
      --this.shake;
    }

    if (this.inGround) {
      int j = this.world.getTypeId(this.d, this.e, this.f);
      int k = this.world.getData(this.d, this.e, this.f);

      if (j == this.g && k == this.h) {
        ++this.j;
        if (this.j == 1200) {
          this.die();
        }
      } else {
        this.inGround = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.j = 0;
        this.at = 0;
      }
    } else {
      ++this.at;
      Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true);

      vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            this.world
                .getVec3DPool()
                .create(
                    movingobjectposition.pos.c,
                    movingobjectposition.pos.d,
                    movingobjectposition.pos.e);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      int l;
      float f1;

      for (l = 0; l < list.size(); ++l) {
        Entity entity1 = (Entity) list.get(l);

        if (entity1.L() && (entity1 != this.shooter || this.at >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.grow((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      float f2;
      float f3;

      if (movingobjectposition != null) {
        // CraftBukkit start
        Projectile projectile = (Projectile) this.getBukkitEntity();
        ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
        this.world.getServer().getPluginManager().callEvent(phe);
        // CraftBukkit end
        if (movingobjectposition.entity != null) {
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int i1 = MathHelper.f((double) f2 * this.damage);

          if (this.d()) {
            i1 += this.random.nextInt(i1 / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shooter == null) {
            damagesource = DamageSource.arrow(this, this);
          } else {
            damagesource = DamageSource.arrow(this, this.shooter);
          }

          // CraftBukkit start - moved damage call
          if (movingobjectposition.entity.damageEntity(damagesource, i1)) {
            if (this.isBurning()
                && !(movingobjectposition.entity instanceof EntityEnderman)
                && (!(movingobjectposition.entity instanceof EntityPlayer)
                    || !(this.shooter instanceof EntityPlayer)
                    || this.world
                        .pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a
                                     // player.
              EntityCombustByEntityEvent combustEvent =
                  new EntityCombustByEntityEvent(
                      this.getBukkitEntity(), entity.getBukkitEntity(), 5);
              org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);

              if (!combustEvent.isCancelled()) {
                movingobjectposition.entity.setOnFire(combustEvent.getDuration());
              }
              // CraftBukkit end
            }

            // if (movingobjectposition.entity.damageEntity(damagesource, i1)) { // CraftBukkit -
            // moved up
            if (movingobjectposition.entity instanceof EntityLiving) {
              EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;

              if (!this.world.isStatic) {
                entityliving.r(entityliving.bJ() + 1);
              }

              if (this.av > 0) {
                f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

                if (f3 > 0.0F) {
                  movingobjectposition.entity.g(
                      this.motX * (double) this.av * 0.6000000238418579D / (double) f3,
                      0.1D,
                      this.motZ * (double) this.av * 0.6000000238418579D / (double) f3);
                }
              }

              if (this.shooter != null) {
                EnchantmentThorns.a(this.shooter, entityliving, this.random);
              }

              if (this.shooter != null
                  && movingobjectposition.entity != this.shooter
                  && movingobjectposition.entity instanceof EntityHuman
                  && this.shooter instanceof EntityPlayer) {
                ((EntityPlayer) this.shooter).playerConnection.sendPacket(new Packet70Bed(6, 0));
              }
            }

            this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            if (!(movingobjectposition.entity instanceof EntityEnderman)) {
              this.die();
            }
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.at = 0;
          }
        } else {
          this.d = movingobjectposition.b;
          this.e = movingobjectposition.c;
          this.f = movingobjectposition.d;
          this.g = this.world.getTypeId(this.d, this.e, this.f);
          this.h = this.world.getData(this.d, this.e, this.f);
          this.motX = (double) ((float) (movingobjectposition.pos.c - this.locX));
          this.motY = (double) ((float) (movingobjectposition.pos.d - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.pos.e - this.locZ));
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
          this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
          this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
          this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.e(false);
          if (this.g != 0) {
            Block.byId[this.g].a(this.world, this.d, this.e, this.f, this);
          }
        }
      }

      if (this.d()) {
        for (l = 0; l < 4; ++l) {
          this.world.addParticle(
              "crit",
              this.locX + this.motX * (double) l / 4.0D,
              this.locY + this.motY * (double) l / 4.0D,
              this.locZ + this.motZ * (double) l / 4.0D,
              -this.motX,
              -this.motY + 0.2D,
              -this.motZ);
        }
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);

      for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D);
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f4 = 0.99F;

      f1 = 0.05F;
      if (this.H()) {
        for (int j1 = 0; j1 < 4; ++j1) {
          f3 = 0.25F;
          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f4 = 0.8F;
      }

      this.motX *= (double) f4;
      this.motY *= (double) f4;
      this.motZ *= (double) f4;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
      this.D();
    }
  }
Example #19
0
  public void h() {
    super.h();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.lastYaw =
          this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
      this.lastPitch =
          this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
    }

    Block block = this.world.getType(this.d, this.e, this.f);

    if (block.getMaterial() != Material.AIR) {
      block.updateShape(this.world, this.d, this.e, this.f);
      AxisAlignedBB axisalignedbb = block.a(this.world, this.d, this.e, this.f);

      if (axisalignedbb != null && axisalignedbb.a(Vec3D.a(this.locX, this.locY, this.locZ))) {
        this.inGround = true;
      }
    }

    if (this.shake > 0) {
      --this.shake;
    }

    if (this.inGround) {
      int i = this.world.getData(this.d, this.e, this.f);

      if (block == this.g && i == this.h) {
        ++this.at;
        if (this.at == 1200) {
          this.die();
        }
      } else {
        this.inGround = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.at = 0;
        this.au = 0;
      }
    } else {
      ++this.au;
      Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition =
          this.world.rayTrace(vec3d, vec3d1, false, true, false);

      vec3d = Vec3D.a(this.locX, this.locY, this.locZ);
      vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            Vec3D.a(
                movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      int j;
      float f1;

      for (j = 0; j < list.size(); ++j) {
        Entity entity1 = (Entity) list.get(j);

        if (entity1.Q() && (entity1 != this.shooter || this.au >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.grow((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null
          && movingobjectposition.entity != null
          && movingobjectposition.entity instanceof EntityHuman) {
        EntityHuman entityhuman = (EntityHuman) movingobjectposition.entity;

        if (entityhuman.abilities.isInvulnerable
            || this.shooter instanceof EntityHuman
                && !((EntityHuman) this.shooter).a(entityhuman)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;

      if (movingobjectposition != null) {
        org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(
            this); // CraftBukkit - Call event

        if (movingobjectposition.entity != null) {
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int k = MathHelper.f((double) f2 * this.damage);

          if (this.isCritical()) {
            k += this.random.nextInt(k / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shooter == null) {
            damagesource = DamageSource.arrow(this, this);
          } else {
            damagesource = DamageSource.arrow(this, this.shooter);
          }

          // CraftBukkit start - Moved damage call
          if (movingobjectposition.entity.damageEntity(damagesource, k)) {
            if (this.isBurning()
                && !(movingobjectposition.entity instanceof EntityEnderman)
                && (!(movingobjectposition.entity instanceof EntityPlayer)
                    || !(this.shooter instanceof EntityPlayer)
                    || this.world
                        .pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a
                                     // player
              EntityCombustByEntityEvent combustEvent =
                  new EntityCombustByEntityEvent(
                      this.getBukkitEntity(), entity.getBukkitEntity(), 5);
              org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);

              if (!combustEvent.isCancelled()) {
                movingobjectposition.entity.setOnFire(combustEvent.getDuration());
              }
              // CraftBukkit end
            }

            // if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) { //
            // CraftBukkit - moved up
            if (movingobjectposition.entity instanceof EntityLiving) {
              EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;

              if (!this.world.isStatic) {
                entityliving.p(entityliving.aY() + 1);
              }

              if (this.knockbackStrength > 0) {
                f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
                if (f3 > 0.0F) {
                  movingobjectposition.entity.g(
                      this.motX
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3,
                      0.1D,
                      this.motZ
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3);
                }
              }

              if (this.shooter != null && this.shooter instanceof EntityLiving) {
                EnchantmentManager.a(entityliving, this.shooter);
                EnchantmentManager.b((EntityLiving) this.shooter, entityliving);
              }

              if (this.shooter != null
                  && movingobjectposition.entity != this.shooter
                  && movingobjectposition.entity instanceof EntityHuman
                  && this.shooter instanceof EntityPlayer) {
                ((EntityPlayer) this.shooter)
                    .playerConnection.sendPacket(new PacketPlayOutGameStateChange(6, 0.0F));
              }
            }

            this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            if (!(movingobjectposition.entity instanceof EntityEnderman)) {
              this.die();
            }
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.au = 0;
          }
        } else {
          this.d = movingobjectposition.b;
          this.e = movingobjectposition.c;
          this.f = movingobjectposition.d;
          this.g = this.world.getType(d, e, f); // CraftBukkit - Get correct block for storage
          this.h = this.world.getData(this.d, this.e, this.f);
          this.motX = (double) ((float) (movingobjectposition.pos.a - this.locX));
          this.motY = (double) ((float) (movingobjectposition.pos.b - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.pos.c - this.locZ));
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
          this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
          this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
          this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.setCritical(false);
          if (this.g.getMaterial() != Material.AIR) {
            this.g.a(this.world, this.d, this.e, this.f, (Entity) this);
          }
        }
      }

      if (this.isCritical()) {
        for (j = 0; j < 4; ++j) {
          this.world.addParticle(
              "crit",
              this.locX + this.motX * (double) j / 4.0D,
              this.locY + this.motY * (double) j / 4.0D,
              this.locZ + this.motZ * (double) j / 4.0D,
              -this.motX,
              -this.motY + 0.2D,
              -this.motZ);
        }
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);

      for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D);
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f4 = 0.99F;

      f1 = 0.05F;
      if (this.L()) {
        for (int l = 0; l < 4; ++l) {
          f3 = 0.25F;
          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f4 = 0.8F;
      }

      if (this.K()) {
        this.extinguish();
      }

      this.motX *= (double) f4;
      this.motY *= (double) f4;
      this.motZ *= (double) f4;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
      this.H();
    }
  }
Example #20
0
public abstract class Entity {

  private static int a = 0;
  public int g;
  public double h;
  public boolean i;
  public Entity j;
  public Entity k;
  public World l;
  public double m;
  public double n;
  public double o;
  public double p;
  public double q;
  public double r;
  public double s;
  public double t;
  public double u;
  public float v;
  public float w;
  public float x;
  public float y;
  public final AxisAlignedBB z = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
  public boolean A;
  public boolean B;
  public boolean C;
  public boolean D;
  public boolean E;
  public boolean F;
  public boolean G;
  public float H;
  public float I;
  public float J;
  public float K;
  public float L;
  protected boolean M;
  protected float N;
  private int b;
  public double O;
  public double P;
  public double Q;
  public float R;
  public float S;
  public boolean T;
  public float U;
  public boolean V;
  protected Random W;
  public int X;
  public int Y;
  public int Z;
  protected int aa;
  protected boolean ab;
  public int ac;
  public int ad;
  private boolean c;
  protected boolean ae;
  private double d;
  private double e;
  public boolean af;
  public int ag;
  public int ah;
  public int ai;

  public Entity(World world) {
    g = a++;
    h = 1.0D;
    i = false;
    A = false;
    D = false;
    E = false;
    F = true;
    G = false;
    H = 0.0F;
    I = 0.6F;
    J = 1.8F;
    K = 0.0F;
    L = 0.0F;
    M = true;
    N = 0.0F;
    b = 1;
    R = 0.0F;
    S = 0.0F;
    T = false;
    U = 0.0F;
    V = false;
    W = new Random();
    X = 0;
    Y = 1;
    Z = 0;
    aa = 300;
    ab = false;
    ac = 0;
    ad = 300;
    c = true;
    ae = false;
    af = false;
    l = world;
    a(0.0D, 0.0D, 0.0D);
  }

  public boolean equals(Object obj) {
    if (obj instanceof Entity) {
      return ((Entity) obj).g == g;
    } else {
      return false;
    }
  }

  public int hashCode() {
    return g;
  }

  public void l() {
    G = true;
  }

  protected void a(float f1, float f2) {
    I = f1;
    J = f2;
  }

  protected void b(float f1, float f2) {
    v = f1;
    w = f2;
  }

  public void a(double d1, double d2, double d3) {
    p = d1;
    q = d2;
    r = d3;
    float f1 = I / 2.0F;
    float f2 = J;

    z.c(
        d1 - (double) f1,
        (d2 - (double) H) + (double) R,
        d3 - (double) f1,
        d1 + (double) f1,
        (d2 - (double) H) + (double) R + (double) f2,
        d3 + (double) f1);
  }

  public void b_() {
    m();
  }

  public void m() {
    if (k != null && k.G) {
      k = null;
    }
    X++;
    K = L;
    m = p;
    n = q;
    o = r;
    y = w;
    x = v;
    if (r()) {
      if (!ab && !c) {
        float f1 =
            MathHelper.a(s * s * 0.20000000298023224D + t * t + u * u * 0.20000000298023224D)
                * 0.2F;

        if (f1 > 1.0F) {
          f1 = 1.0F;
        }
        l.a(this, "random.splash", f1, 1.0F + (W.nextFloat() - W.nextFloat()) * 0.4F);
        float f2 = MathHelper.b(z.b);

        for (int i1 = 0; (float) i1 < 1.0F + I * 20F; i1++) {
          float f3 = (W.nextFloat() * 2.0F - 1.0F) * I;
          float f5 = (W.nextFloat() * 2.0F - 1.0F) * I;

          l.a(
              "bubble",
              p + (double) f3,
              f2 + 1.0F,
              r + (double) f5,
              s,
              t - (double) (W.nextFloat() * 0.2F),
              u);
        }

        for (int j1 = 0; (float) j1 < 1.0F + I * 20F; j1++) {
          float f4 = (W.nextFloat() * 2.0F - 1.0F) * I;
          float f6 = (W.nextFloat() * 2.0F - 1.0F) * I;

          l.a("splash", p + (double) f4, f2 + 1.0F, r + (double) f6, s, t, u);
        }
      }
      N = 0.0F;
      ab = true;
      Z = 0;
    } else {
      ab = false;
    }
    if (l.z) {
      Z = 0;
    } else if (Z > 0) {
      if (ae) {
        Z -= 4;
        if (Z < 0) {
          Z = 0;
        }
      } else {
        if (Z % 20 == 0) {
          a(((Entity) (null)), 1);
        }
        Z--;
      }
    }
    if (t()) {
      n();
    }
    if (q < -64D) {
      o();
    }
    c = false;
  }

  protected void n() {
    if (!ae) {
      a(((Entity) (null)), 4);
      Z = 600;
    }
  }

  protected void o() {
    l();
  }

  public boolean b(double d1, double d2, double d3) {
    AxisAlignedBB axisalignedbb = z.c(d1, d2, d3);
    List list = l.a(this, axisalignedbb);

    if (list.size() > 0) {
      return false;
    }
    return !l.b(axisalignedbb);
  }

  public void c(double d1, double d2, double d3) {
    if (T) {
      z.d(d1, d2, d3);
      p = (z.a + z.d) / 2D;
      q = (z.b + (double) H) - (double) R;
      r = (z.c + z.f) / 2D;
      return;
    }
    double d4 = p;
    double d5 = r;
    double d6 = d1;
    double d7 = d2;
    double d8 = d3;
    AxisAlignedBB axisalignedbb = z.b();
    boolean flag = A && p();

    if (flag) {
      double d9 = 0.050000000000000003D;

      for (; d1 != 0.0D && l.a(this, z.c(d1, -1D, 0.0D)).size() == 0; d6 = d1) {
        if (d1 < d9 && d1 >= -d9) {
          d1 = 0.0D;
          continue;
        }
        if (d1 > 0.0D) {
          d1 -= d9;
        } else {
          d1 += d9;
        }
      }

      for (; d3 != 0.0D && l.a(this, z.c(0.0D, -1D, d3)).size() == 0; d8 = d3) {
        if (d3 < d9 && d3 >= -d9) {
          d3 = 0.0D;
          continue;
        }
        if (d3 > 0.0D) {
          d3 -= d9;
        } else {
          d3 += d9;
        }
      }
    }
    List list = l.a(this, z.a(d1, d2, d3));

    for (int i1 = 0; i1 < list.size(); i1++) {
      d2 = ((AxisAlignedBB) list.get(i1)).b(z, d2);
    }

    z.d(0.0D, d2, 0.0D);
    if (!F && d7 != d2) {
      d1 = d2 = d3 = 0.0D;
    }
    boolean flag1 = A || d7 != d2 && d7 < 0.0D;

    for (int j1 = 0; j1 < list.size(); j1++) {
      d1 = ((AxisAlignedBB) list.get(j1)).a(z, d1);
    }

    z.d(d1, 0.0D, 0.0D);
    if (!F && d6 != d1) {
      d1 = d2 = d3 = 0.0D;
    }
    for (int k1 = 0; k1 < list.size(); k1++) {
      d3 = ((AxisAlignedBB) list.get(k1)).c(z, d3);
    }

    z.d(0.0D, 0.0D, d3);
    if (!F && d8 != d3) {
      d1 = d2 = d3 = 0.0D;
    }
    if (S > 0.0F && flag1 && R < 0.05F && (d6 != d1 || d8 != d3)) {
      double d10 = d1;
      double d12 = d2;
      double d14 = d3;

      d1 = d6;
      d2 = S;
      d3 = d8;
      AxisAlignedBB axisalignedbb1 = z.b();

      z.b(axisalignedbb);
      List list1 = l.a(this, z.a(d1, d2, d3));

      for (int j2 = 0; j2 < list1.size(); j2++) {
        d2 = ((AxisAlignedBB) list1.get(j2)).b(z, d2);
      }

      z.d(0.0D, d2, 0.0D);
      if (!F && d7 != d2) {
        d1 = d2 = d3 = 0.0D;
      }
      for (int k2 = 0; k2 < list1.size(); k2++) {
        d1 = ((AxisAlignedBB) list1.get(k2)).a(z, d1);
      }

      z.d(d1, 0.0D, 0.0D);
      if (!F && d6 != d1) {
        d1 = d2 = d3 = 0.0D;
      }
      for (int l2 = 0; l2 < list1.size(); l2++) {
        d3 = ((AxisAlignedBB) list1.get(l2)).c(z, d3);
      }

      z.d(0.0D, 0.0D, d3);
      if (!F && d8 != d3) {
        d1 = d2 = d3 = 0.0D;
      }
      if (d10 * d10 + d14 * d14 >= d1 * d1 + d3 * d3) {
        d1 = d10;
        d2 = d12;
        d3 = d14;
        z.b(axisalignedbb1);
      } else {
        R += 0.5D;
      }
    }
    p = (z.a + z.d) / 2D;
    q = (z.b + (double) H) - (double) R;
    r = (z.c + z.f) / 2D;
    B = d6 != d1 || d8 != d3;
    C = d7 != d2;
    A = d7 != d2 && d7 < 0.0D;
    D = B || C;
    a(d2, A);
    if (d6 != d1) {
      s = 0.0D;
    }
    if (d7 != d2) {
      t = 0.0D;
    }
    if (d8 != d3) {
      u = 0.0D;
    }
    double d11 = p - d4;
    double d13 = r - d5;

    if (M && !flag) {
      L += (double) MathHelper.a(d11 * d11 + d13 * d13) * 0.59999999999999998D;
      int k3 = MathHelper.b(p);
      int i4 = MathHelper.b(q - 0.20000000298023224D - (double) H);
      int l1 = MathHelper.b(r);
      int i3 = l.a(k3, i4, l1);

      if (L > (float) b && i3 > 0) {
        b++;
        StepSound stepsound = Block.m[i3].bq;

        if (l.a(k3, i4 + 1, l1) == Block.aS.bh) {
          stepsound = Block.aS.bq;
          l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
        } else if (!Block.m[i3].bs.d()) {
          l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
        }
        Block.m[i3].b(l, k3, i4, l1, this);
      }
    }
    int l3 = MathHelper.b(z.a);
    int j4 = MathHelper.b(z.b);
    int i2 = MathHelper.b(z.c);
    int j3 = MathHelper.b(z.d);
    int k4 = MathHelper.b(z.e);
    int l4 = MathHelper.b(z.f);

    for (int i5 = l3; i5 <= j3; i5++) {
      for (int j5 = j4; j5 <= k4; j5++) {
        for (int k5 = i2; k5 <= l4; k5++) {
          int l5 = l.a(i5, j5, k5);

          if (l5 > 0) {
            Block.m[l5].a(l, i5, j5, k5, this);
          }
        }
      }
    }

    R *= 0.4F;
    boolean flag2 = r();

    if (l.c(z)) {
      b(1);
      if (!flag2) {
        Z++;
        if (Z == 0) {
          Z = 300;
        }
      }
    } else if (Z <= 0) {
      Z = -Y;
    }
    if (flag2 && Z > 0) {
      l.a(this, "random.fizz", 0.7F, 1.6F + (W.nextFloat() - W.nextFloat()) * 0.4F);
      Z = -Y;
    }
  }

  protected void a(double d1, boolean flag) {
    if (flag) {
      if (N > 0.0F) {
        a(N);
        N = 0.0F;
      }
    } else if (d1 < 0.0D) {
      N -= d1;
    }
  }

  public boolean p() {
    return false;
  }

  public AxisAlignedBB q() {
    return null;
  }

  protected void b(int i1) {
    if (!ae) {
      a(((Entity) (null)), i1);
    }
  }

  protected void a(float f1) {}

  public boolean r() {
    return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.f, this);
  }

  public boolean a(Material material) {
    double d1 = q + (double) s();
    int i1 = MathHelper.b(p);
    int j1 = MathHelper.d(MathHelper.b(d1));
    int k1 = MathHelper.b(r);
    int l1 = l.a(i1, j1, k1);

    if (l1 != 0 && Block.m[l1].bs == material) {
      float f1 = BlockFluids.b(l.b(i1, j1, k1)) - 0.1111111F;
      float f2 = (float) (j1 + 1) - f1;

      return d1 < (double) f2;
    } else {
      return false;
    }
  }

  public float s() {
    return 0.0F;
  }

  public boolean t() {
    return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.g);
  }

  public void a(float f1, float f2, float f3) {
    float f4 = MathHelper.c(f1 * f1 + f2 * f2);

    if (f4 < 0.01F) {
      return;
    }
    if (f4 < 1.0F) {
      f4 = 1.0F;
    }
    f4 = f3 / f4;
    f1 *= f4;
    f2 *= f4;
    float f5 = MathHelper.a((v * 3.141593F) / 180F);
    float f6 = MathHelper.b((v * 3.141593F) / 180F);

    s += f1 * f6 - f2 * f5;
    u += f2 * f6 + f1 * f5;
  }

  public float b(float f1) {
    int i1 = MathHelper.b(p);
    double d1 = (z.e - z.b) * 0.66000000000000003D;
    int j1 = MathHelper.b((q - (double) H) + d1);
    int k1 = MathHelper.b(r);

    return l.k(i1, j1, k1);
  }

  public void b(double d1, double d2, double d3, float f1, float f2) {
    m = p = d1;
    n = q = d2;
    o = r = d3;
    x = v = f1;
    y = w = f2;
    R = 0.0F;
    double d4 = x - f1;

    if (d4 < -180D) {
      x += 360F;
    }
    if (d4 >= 180D) {
      x -= 360F;
    }
    a(p, q, r);
    b(f1, f2);
  }

  public void c(double d1, double d2, double d3, float f1, float f2) {
    m = p = d1;
    n = q = d2 + (double) H;
    o = r = d3;
    v = f1;
    w = f2;
    a(p, q, r);
  }

  public float a(Entity entity) {
    float f1 = (float) (p - entity.p);
    float f2 = (float) (q - entity.q);
    float f3 = (float) (r - entity.r);

    return MathHelper.c(f1 * f1 + f2 * f2 + f3 * f3);
  }

  public double d(double d1, double d2, double d3) {
    double d4 = p - d1;
    double d5 = q - d2;
    double d6 = r - d3;

    return d4 * d4 + d5 * d5 + d6 * d6;
  }

  public double e(double d1, double d2, double d3) {
    double d4 = p - d1;
    double d5 = q - d2;
    double d6 = r - d3;

    return (double) MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
  }

  public double b(Entity entity) {
    double d1 = p - entity.p;
    double d2 = q - entity.q;
    double d3 = r - entity.r;

    return d1 * d1 + d2 * d2 + d3 * d3;
  }

  public void b(EntityPlayer entityplayer) {}

  public void c(Entity entity) {
    if (entity.j == this || entity.k == this) {
      return;
    }
    double d1 = entity.p - p;
    double d2 = entity.r - r;
    double d3 = MathHelper.a(d1, d2);

    if (d3 >= 0.0099999997764825821D) {
      d3 = MathHelper.a(d3);
      d1 /= d3;
      d2 /= d3;
      double d4 = 1.0D / d3;

      if (d4 > 1.0D) {
        d4 = 1.0D;
      }
      d1 *= d4;
      d2 *= d4;
      d1 *= 0.05000000074505806D;
      d2 *= 0.05000000074505806D;
      d1 *= 1.0F - U;
      d2 *= 1.0F - U;
      f(-d1, 0.0D, -d2);
      entity.f(d1, 0.0D, d2);
    }
  }

  public void f(double d1, double d2, double d3) {
    s += d1;
    t += d2;
    u += d3;
  }

  protected void u() {
    E = true;
  }

  public boolean a(Entity entity, int i1) {
    u();
    return false;
  }

  public boolean c_() {
    return false;
  }

  public boolean v() {
    return false;
  }

  public void b(Entity entity, int i1) {}

  public boolean c(NBTTagCompound nbttagcompound) {
    String s1 = w();

    if (G || s1 == null) {
      return false;
    } else {
      nbttagcompound.a("id", s1);
      d(nbttagcompound);
      return true;
    }
  }

  public void d(NBTTagCompound nbttagcompound) {
    nbttagcompound.a("Pos", a(new double[] {p, q, r}));
    nbttagcompound.a("Motion", a(new double[] {s, t, u}));
    nbttagcompound.a("Rotation", a(new float[] {v, w}));
    nbttagcompound.a("FallDistance", N);
    nbttagcompound.a("Fire", (short) Z);
    nbttagcompound.a("Air", (short) ad);
    nbttagcompound.a("OnGround", A);
    a(nbttagcompound);
  }

  public void e(NBTTagCompound nbttagcompound) {
    NBTTagList nbttaglist = nbttagcompound.k("Pos");
    NBTTagList nbttaglist1 = nbttagcompound.k("Motion");
    NBTTagList nbttaglist2 = nbttagcompound.k("Rotation");

    a(0.0D, 0.0D, 0.0D);
    s = ((NBTTagDouble) nbttaglist1.a(0)).a;
    t = ((NBTTagDouble) nbttaglist1.a(1)).a;
    u = ((NBTTagDouble) nbttaglist1.a(2)).a;
    m = O = p = ((NBTTagDouble) nbttaglist.a(0)).a;
    n = P = q = ((NBTTagDouble) nbttaglist.a(1)).a;
    o = Q = r = ((NBTTagDouble) nbttaglist.a(2)).a;
    x = v = ((NBTTagFloat) nbttaglist2.a(0)).a;
    y = w = ((NBTTagFloat) nbttaglist2.a(1)).a;
    N = nbttagcompound.f("FallDistance");
    Z = nbttagcompound.c("Fire");
    ad = nbttagcompound.c("Air");
    A = nbttagcompound.l("OnGround");
    a(p, q, r);
    b(nbttagcompound);
  }

  protected final String w() {
    return EntityList.b(this);
  }

  protected abstract void b(NBTTagCompound nbttagcompound);

  protected abstract void a(NBTTagCompound nbttagcompound);

  protected NBTTagList a(double ad1[]) {
    NBTTagList nbttaglist = new NBTTagList();
    double ad2[] = ad1;
    int i1 = ad2.length;

    for (int j1 = 0; j1 < i1; j1++) {
      double d1 = ad2[j1];

      nbttaglist.a(new NBTTagDouble(d1));
    }

    return nbttaglist;
  }

  protected NBTTagList a(float af1[]) {
    NBTTagList nbttaglist = new NBTTagList();
    float af2[] = af1;
    int i1 = af2.length;

    for (int j1 = 0; j1 < i1; j1++) {
      float f1 = af2[j1];

      nbttaglist.a(new NBTTagFloat(f1));
    }

    return nbttaglist;
  }

  public EntityItem b(int i1, int j1) {
    return a(i1, j1, 0.0F);
  }

  public EntityItem a(int i1, int j1, float f1) {
    EntityItem entityitem = new EntityItem(l, p, q + (double) f1, r, new ItemStack(i1, j1));

    entityitem.c = 10;
    l.a(entityitem);
    return entityitem;
  }

  public boolean x() {
    return !G;
  }

  public boolean y() {
    int i1 = MathHelper.b(p);
    int j1 = MathHelper.b(q + (double) s());
    int k1 = MathHelper.b(r);

    return l.d(i1, j1, k1);
  }

  public boolean a(EntityPlayer entityplayer) {
    return false;
  }

  public AxisAlignedBB d(Entity entity) {
    return null;
  }

  public void z() {
    if (k.G) {
      k = null;
      return;
    }
    s = 0.0D;
    t = 0.0D;
    u = 0.0D;
    b_();
    k.A();
    e += k.v - k.x;
    d += k.w - k.y;
    for (; e >= 180D; e -= 360D) {;
    }
    for (; e < -180D; e += 360D) {;
    }
    for (; d >= 180D; d -= 360D) {;
    }
    for (; d < -180D; d += 360D) {;
    }
    double d1 = e * 0.5D;
    double d2 = d * 0.5D;
    float f1 = 10F;

    if (d1 > (double) f1) {
      d1 = f1;
    }
    if (d1 < (double) (-f1)) {
      d1 = -f1;
    }
    if (d2 > (double) f1) {
      d2 = f1;
    }
    if (d2 < (double) (-f1)) {
      d2 = -f1;
    }
    e -= d1;
    d -= d2;
    v += d1;
    w += d2;
  }

  public void A() {
    j.a(p, q + j() + j.B(), r);
  }

  public double B() {
    return (double) H;
  }

  public double j() {
    return (double) J * 0.75D;
  }

  public void e(Entity entity) {
    d = 0.0D;
    e = 0.0D;
    if (entity == null) {
      if (k != null) {
        c(k.p, k.z.b + (double) k.J, k.r, v, w);
        k.j = null;
      }
      k = null;
      return;
    }
    if (k == entity) {
      k.j = null;
      k = null;
      c(entity.p, entity.z.b + (double) entity.J, entity.r, v, w);
      return;
    }
    if (k != null) {
      k.j = null;
    }
    if (entity.j != null) {
      entity.j.k = null;
    }
    k = entity;
    entity.j = this;
  }

  public Vec3D C() {
    return null;
  }

  public void D() {}

  public int[] E() {
    return null;
  }
}
Example #21
0
  public void move(double d0, double d1, double d2) {
    if (this.T) {
      this.a(this.getBoundingBox().c(d0, d1, d2));
      this.recalcPosition();
    } else {
      this.world.methodProfiler.a("move");
      double d3 = this.locX;
      double d4 = this.locY;
      double d5 = this.locZ;

      if (this.H) {
        this.H = false;
        d0 *= 0.25D;
        d1 *= 0.05000000074505806D;
        d2 *= 0.25D;
        this.motX = 0.0D;
        this.motY = 0.0D;
        this.motZ = 0.0D;
      }

      double d6 = d0;
      double d7 = d1;
      double d8 = d2;
      boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman;

      if (flag) {
        double d9;

        for (d9 = 0.05D;
            d0 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, 0.0D)).isEmpty();
            d6 = d0) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }
        }

        for (;
            d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(0.0D, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }

        for (;
            d0 != 0.0D
                && d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }

          d6 = d0;
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }
      }

      List list = this.world.getCubes(this, this.getBoundingBox().a(d0, d1, d2));
      AxisAlignedBB axisalignedbb = this.getBoundingBox();

      AxisAlignedBB axisalignedbb1;

      for (Iterator iterator = list.iterator();
          iterator.hasNext();
          d1 = axisalignedbb1.b(this.getBoundingBox(), d1)) {
        axisalignedbb1 = (AxisAlignedBB) iterator.next();
      }

      this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
      boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D;

      AxisAlignedBB axisalignedbb2;
      Iterator iterator1;

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d0 = axisalignedbb2.a(this.getBoundingBox(), d0)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(d0, 0.0D, 0.0D));

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d2 = axisalignedbb2.c(this.getBoundingBox(), d2)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(0.0D, 0.0D, d2));
      if (this.S > 0.0F && flag1 && (d6 != d0 || d8 != d2)) {
        double d10 = d0;
        double d11 = d1;
        double d12 = d2;
        AxisAlignedBB axisalignedbb3 = this.getBoundingBox();

        this.a(axisalignedbb);
        d1 = (double) this.S;
        List list1 = this.world.getCubes(this, this.getBoundingBox().a(d6, d1, d8));
        AxisAlignedBB axisalignedbb4 = this.getBoundingBox();
        AxisAlignedBB axisalignedbb5 = axisalignedbb4.a(d6, 0.0D, d8);
        double d13 = d1;

        AxisAlignedBB axisalignedbb6;

        for (Iterator iterator2 = list1.iterator();
            iterator2.hasNext();
            d13 = axisalignedbb6.b(axisalignedbb5, d13)) {
          axisalignedbb6 = (AxisAlignedBB) iterator2.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, d13, 0.0D);
        double d14 = d6;

        AxisAlignedBB axisalignedbb7;

        for (Iterator iterator3 = list1.iterator();
            iterator3.hasNext();
            d14 = axisalignedbb7.a(axisalignedbb4, d14)) {
          axisalignedbb7 = (AxisAlignedBB) iterator3.next();
        }

        axisalignedbb4 = axisalignedbb4.c(d14, 0.0D, 0.0D);
        double d15 = d8;

        AxisAlignedBB axisalignedbb8;

        for (Iterator iterator4 = list1.iterator();
            iterator4.hasNext();
            d15 = axisalignedbb8.c(axisalignedbb4, d15)) {
          axisalignedbb8 = (AxisAlignedBB) iterator4.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, 0.0D, d15);
        AxisAlignedBB axisalignedbb9 = this.getBoundingBox();
        double d16 = d1;

        AxisAlignedBB axisalignedbb10;

        for (Iterator iterator5 = list1.iterator();
            iterator5.hasNext();
            d16 = axisalignedbb10.b(axisalignedbb9, d16)) {
          axisalignedbb10 = (AxisAlignedBB) iterator5.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, d16, 0.0D);
        double d17 = d6;

        AxisAlignedBB axisalignedbb11;

        for (Iterator iterator6 = list1.iterator();
            iterator6.hasNext();
            d17 = axisalignedbb11.a(axisalignedbb9, d17)) {
          axisalignedbb11 = (AxisAlignedBB) iterator6.next();
        }

        axisalignedbb9 = axisalignedbb9.c(d17, 0.0D, 0.0D);
        double d18 = d8;

        AxisAlignedBB axisalignedbb12;

        for (Iterator iterator7 = list1.iterator();
            iterator7.hasNext();
            d18 = axisalignedbb12.c(axisalignedbb9, d18)) {
          axisalignedbb12 = (AxisAlignedBB) iterator7.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, 0.0D, d18);
        double d19 = d14 * d14 + d15 * d15;
        double d20 = d17 * d17 + d18 * d18;

        if (d19 > d20) {
          d0 = d14;
          d2 = d15;
          this.a(axisalignedbb4);
        } else {
          d0 = d17;
          d2 = d18;
          this.a(axisalignedbb9);
        }

        d1 = (double) (-this.S);

        AxisAlignedBB axisalignedbb13;

        for (Iterator iterator8 = list1.iterator();
            iterator8.hasNext();
            d1 = axisalignedbb13.b(this.getBoundingBox(), d1)) {
          axisalignedbb13 = (AxisAlignedBB) iterator8.next();
        }

        this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
        if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) {
          d0 = d10;
          d1 = d11;
          d2 = d12;
          this.a(axisalignedbb3);
        }
      }

      this.world.methodProfiler.b();
      this.world.methodProfiler.a("rest");
      this.recalcPosition();
      this.positionChanged = d6 != d0 || d8 != d2;
      this.E = d7 != d1;
      this.onGround = this.E && d7 < 0.0D;
      this.F = this.positionChanged || this.E;
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D);
      int k = MathHelper.floor(this.locZ);
      BlockPosition blockposition = new BlockPosition(i, j, k);
      Block block = this.world.getType(blockposition).getBlock();

      if (block.getMaterial() == Material.AIR) {
        Block block1 = this.world.getType(blockposition.down()).getBlock();

        if (block1 instanceof BlockFence
            || block1 instanceof BlockCobbleWall
            || block1 instanceof BlockFenceGate) {
          block = block1;
          blockposition = blockposition.down();
        }
      }

      this.a(d1, this.onGround, block, blockposition);
      if (d6 != d0) {
        this.motX = 0.0D;
      }

      if (d8 != d2) {
        this.motZ = 0.0D;
      }

      if (d7 != d1) {
        block.a(this.world, this);
      }

      if (this.r_() && !flag && this.vehicle == null) {
        double d21 = this.locX - d3;
        double d22 = this.locY - d4;
        double d23 = this.locZ - d5;

        if (block != Blocks.LADDER) {
          d22 = 0.0D;
        }

        if (block != null && this.onGround) {
          block.a(this.world, blockposition, this);
        }

        this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
        this.N =
            (float)
                ((double) this.N
                    + (double) MathHelper.sqrt(d21 * d21 + d22 * d22 + d23 * d23) * 0.6D);
        if (this.N > (float) this.h && block.getMaterial() != Material.AIR) {
          this.h = (int) this.N + 1;
          if (this.V()) {
            float f =
                MathHelper.sqrt(
                        this.motX * this.motX * 0.20000000298023224D
                            + this.motY * this.motY
                            + this.motZ * this.motZ * 0.20000000298023224D)
                    * 0.35F;

            if (f > 1.0F) {
              f = 1.0F;
            }

            this.makeSound(
                this.P(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
          }

          this.a(blockposition, block);
        }
      }

      try {
        this.checkBlockCollisions();
      } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision");
        CrashReportSystemDetails crashreportsystemdetails =
            crashreport.a("Entity being checked for collision");

        this.appendEntityCrashDetails(crashreportsystemdetails);
        throw new ReportedException(crashreport);
      }

      boolean flag2 = this.U();

      if (this.world.e(this.getBoundingBox().shrink(0.001D, 0.001D, 0.001D))) {
        this.burn(1);
        if (!flag2) {
          ++this.fireTicks;
          if (this.fireTicks == 0) {
            this.setOnFire(8);
          }
        }
      } else if (this.fireTicks <= 0) {
        this.fireTicks = -this.maxFireTicks;
      }

      if (flag2 && this.fireTicks > 0) {
        this.makeSound(
            "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
        this.fireTicks = -this.maxFireTicks;
      }

      this.world.methodProfiler.b();
    }
  }
Example #22
0
 public boolean t() {
   return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.g);
 }
  @ForgeSubscribe
  public void DrawBlockHighlightEvent(DrawBlockHighlightEvent evt) {
    World world = evt.player.worldObj;
    double var8 =
        evt.player.lastTickPosX
            + (evt.player.posX - evt.player.lastTickPosX) * (double) evt.partialTicks;
    double var10 =
        evt.player.lastTickPosY
            + (evt.player.posY - evt.player.lastTickPosY) * (double) evt.partialTicks;
    double var12 =
        evt.player.lastTickPosZ
            + (evt.player.posZ - evt.player.lastTickPosZ) * (double) evt.partialTicks;

    boolean isMetalHoe = false;

    if (evt.currentItem != null
        && evt.currentItem.getItem().shiftedIndex != TFCItems.IgInHoe.shiftedIndex
        && evt.currentItem.getItem().shiftedIndex != TFCItems.IgExHoe.shiftedIndex
        && evt.currentItem.getItem().shiftedIndex != TFCItems.SedHoe.shiftedIndex
        && evt.currentItem.getItem().shiftedIndex != TFCItems.MMHoe.shiftedIndex) {
      isMetalHoe = true;
    }

    if (evt.currentItem != null
        && evt.currentItem.getItem() instanceof ItemCustomHoe
        && isMetalHoe
        && PlayerManagerTFC.getInstance().getClientPlayer().hoeMode == 1) {
      int id = world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
      int crop = 0;
      if (id == Block.crops.blockID
          && (world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil.blockID
              || world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil2.blockID)) {
        id = TFCBlocks.tilledSoil.blockID;
        crop = 1;
      }

      if (id == TFCBlocks.tilledSoil.blockID || id == TFCBlocks.tilledSoil2.blockID) {
        TileEntityFarmland te =
            (TileEntityFarmland)
                world.getBlockTileEntity(
                    evt.target.blockX, evt.target.blockY - crop, evt.target.blockZ);
        te.requestNutrientData();

        float timeMultiplier = (float) TFC_Time.daysInYear / 360f;
        int soilMax = (int) (25000 * timeMultiplier);

        // Setup GL for the depthbox
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4ub(
            TFC_Settings.cropNutrientAColor[0],
            TFC_Settings.cropNutrientAColor[1],
            TFC_Settings.cropNutrientAColor[2],
            TFC_Settings.cropNutrientAColor[3]);
        GL11.glDisable(GL11.GL_CULL_FACE);
        // GL11.glLineWidth(6.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);

        double offset = 0;
        double nutrient = 1.02 + ((double) te.nutrients[0] / (double) soilMax) * 0.5;

        drawBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.3333;
        nutrient = 1.02 + ((double) te.nutrients[1] / (double) soilMax) * 0.5;
        GL11.glColor4ub(
            TFC_Settings.cropNutrientBColor[0],
            TFC_Settings.cropNutrientBColor[1],
            TFC_Settings.cropNutrientBColor[2],
            TFC_Settings.cropNutrientBColor[3]);
        drawBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.6666;
        nutrient = 1.02 + ((double) te.nutrients[2] / (double) soilMax) * 0.5;
        GL11.glColor4ub(
            TFC_Settings.cropNutrientCColor[0],
            TFC_Settings.cropNutrientCColor[1],
            TFC_Settings.cropNutrientCColor[2],
            TFC_Settings.cropNutrientCColor[3]);
        drawBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        GL11.glEnable(GL11.GL_CULL_FACE);

        /** Draw the outliens around the boxes */
        GL11.glColor4f(0.1F, 0.1F, 0.1F, 1.0F);
        GL11.glLineWidth(3.0F);
        GL11.glDepthMask(false);

        offset = 0;
        nutrient = 1.02 + ((double) te.nutrients[0] / (double) soilMax) * 0.5;
        drawOutlinedBoundingBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.3333;
        nutrient = 1.02 + ((double) te.nutrients[1] / (double) soilMax) * 0.5;
        drawOutlinedBoundingBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.6666;
        nutrient = 1.02 + ((double) te.nutrients[2] / (double) soilMax) * 0.5;
        drawOutlinedBoundingBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));
      }
    } else if (evt.currentItem != null
        && evt.currentItem.getItem() instanceof ItemCustomHoe
        && PlayerManagerTFC.getInstance().getClientPlayer().hoeMode == 2) {
      int id = world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
      int crop = 0;
      if (id == Block.crops.blockID
          && (world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil.blockID
              || world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil2.blockID)) {
        id = TFCBlocks.tilledSoil.blockID;
        crop = 1;
      }

      if (id == TFCBlocks.tilledSoil.blockID || id == TFCBlocks.tilledSoil2.blockID) {
        boolean water =
            TFC.Blocks.BlockFarmland.isWaterNearby(
                world, evt.target.blockX, evt.target.blockY - crop, evt.target.blockZ);

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if (water) GL11.glColor4ub((byte) 14, (byte) 23, (byte) 212, (byte) 200);
        else GL11.glColor4ub((byte) 0, (byte) 0, (byte) 0, (byte) 200);
        GL11.glDisable(GL11.GL_CULL_FACE);
        // GL11.glLineWidth(6.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);

        drawFace(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + 1,
                    evt.target.blockY + 1.02 - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        GL11.glEnable(GL11.GL_CULL_FACE);
      }
    } else if (evt.currentItem != null
        && evt.currentItem.getItem() instanceof ItemCustomHoe
        && PlayerManagerTFC.getInstance().getClientPlayer().hoeMode == 3) {
      int id = world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
      if (id == Block.crops.blockID
          && (world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil.blockID
              || world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil2.blockID)) {
        TileEntityCrop te =
            (TileEntityCrop)
                world.getBlockTileEntity(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
        CropIndex index = CropManager.getInstance().getCropFromId(te.cropId);
        boolean fullyGrown = te.growth >= index.numGrowthStages;

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if (fullyGrown) GL11.glColor4ub((byte) 64, (byte) 200, (byte) 37, (byte) 200);
        else GL11.glColor4ub((byte) 200, (byte) 37, (byte) 37, (byte) 200);
        GL11.glDisable(GL11.GL_CULL_FACE);
        // GL11.glLineWidth(6.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);

        drawFace(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX,
                    evt.target.blockY + 0.01,
                    evt.target.blockZ,
                    evt.target.blockX + 1,
                    evt.target.blockY + 0.02,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        GL11.glEnable(GL11.GL_CULL_FACE);
      }
    }
  }
  public void l_() {
    if (!this.world.isStatic
        && (this.shooter != null && this.shooter.dead
            || !this.world.isLoaded((int) this.locX, (int) this.locY, (int) this.locZ))) {
      this.die();
    } else {
      super.l_();
      this.setOnFire(1);
      if (this.i) {
        int i = this.world.getTypeId(this.e, this.f, this.g);

        if (i == this.h) {
          ++this.j;
          if (this.j == 600) {
            this.die();
          }

          return;
        }

        this.i = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.j = 0;
        this.au = 0;
      } else {
        ++this.au;
      }

      Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);

      vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
      vec3d1 =
          this.world
              .getVec3DPool()
              .create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            this.world
                .getVec3DPool()
                .create(
                    movingobjectposition.pos.c,
                    movingobjectposition.pos.d,
                    movingobjectposition.pos.e);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      for (int j = 0; j < list.size(); ++j) {
        Entity entity1 = (Entity) list.get(j);

        if (entity1.K() && (!entity1.h(this.shooter) || this.au >= 25)) {
          float f = 0.3F;
          AxisAlignedBB axisalignedbb =
              entity1.boundingBox.grow((double) f, (double) f, (double) f);
          MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null) {
        this.a(movingobjectposition);

        // CraftBukkit start
        if (this.dead) {
          org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
        }
        // CraftBukkit end
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      float f1 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.yaw = (float) (Math.atan2(this.motZ, this.motX) * 180.0D / 3.1415927410125732D) + 90.0F;

      for (this.pitch =
              (float) (Math.atan2((double) f1, this.motY) * 180.0D / 3.1415927410125732D) - 90.0F;
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f2 = this.c();

      if (this.G()) {
        for (int k = 0; k < 4; ++k) {
          float f3 = 0.25F;

          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f2 = 0.8F;
      }

      this.motX += this.dirX;
      this.motY += this.dirY;
      this.motZ += this.dirZ;
      this.motX *= (double) f2;
      this.motY *= (double) f2;
      this.motZ *= (double) f2;
      this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
      this.setPosition(this.locX, this.locY, this.locZ);
    }
  }
Example #25
0
  public void w_() {
    super.w_();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);

      this.lastYaw =
          this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
      this.lastPitch =
          this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
    }

    int i = this.world.getTypeId(this.e, this.f, this.g);

    if (i > 0) {
      Block.byId[i].updateShape(this.world, this.e, this.f, this.g);
      AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.e, this.f, this.g);

      if (axisalignedbb != null && axisalignedbb.a(Vec3D.create(this.locX, this.locY, this.locZ))) {
        this.inGround = true;
      }
    }

    if (this.shake > 0) {
      --this.shake;
    }

    if (this.inGround) {
      i = this.world.getTypeId(this.e, this.f, this.g);
      int j = this.world.getData(this.e, this.f, this.g);

      if (i == this.h && j == this.i) {
        ++this.k;
        if (this.k == 1200) {
          this.die();
        }
      } else {
        this.inGround = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.k = 0;
        this.l = 0;
      }
    } else {
      ++this.l;
      Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 =
          Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true);

      vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
      vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            Vec3D.create(
                movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
      }

      Entity entity = null;
      List list =
          this.world.b(
              (Entity) this,
              this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      int k;
      float f1;

      for (k = 0; k < list.size(); ++k) {
        Entity entity1 = (Entity) list.get(k);

        if (entity1.e_() && (entity1 != this.shooter || this.l >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.b((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 = vec3d.b(movingobjectposition1.f);

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      float f2;

      if (movingobjectposition != null) {
        // CraftBukkit start
        ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(phe);
        // CraftBukkit end
        if (movingobjectposition.entity != null) {
          f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int l = (int) Math.ceil((double) f2 * 2.0D);

          if (this.d) {
            l += this.random.nextInt(l / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shooter == null) {
            damagesource = DamageSource.arrow(this, this);
          } else {
            damagesource = DamageSource.arrow(this, this.shooter);
          }

          // CraftBukkit start
          boolean stick;
          if (entity instanceof EntityLiving) {

            org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
            Projectile projectile = (Projectile) this.getBukkitEntity();

            EntityDamageByEntityEvent event =
                new EntityDamageByEntityEvent(
                    projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l);
            Bukkit.getPluginManager().callEvent(event);

            if (event.isCancelled()) {
              stick = !projectile.doesBounce();
            } else {
              // this function returns if the arrow should stick in or not, i.e. !bounce
              stick = movingobjectposition.entity.damageEntity(damagesource, event.getDamage());
            }
          } else {
            stick = movingobjectposition.entity.damageEntity(damagesource, l);
          }
          if (stick) {
            // CraftBukkit end
            if (movingobjectposition.entity instanceof EntityLiving) {
              ++((EntityLiving) movingobjectposition.entity).aH;
            }

            this.world.makeSound(
                this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            this.die();
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.l = 0;
          }
        } else {
          this.e = movingobjectposition.b;
          this.f = movingobjectposition.c;
          this.g = movingobjectposition.d;
          this.h = this.world.getTypeId(this.e, this.f, this.g);
          this.i = this.world.getData(this.e, this.f, this.g);
          this.motX = (double) ((float) (movingobjectposition.f.a - this.locX));
          this.motY = (double) ((float) (movingobjectposition.f.b - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.f.c - this.locZ));
          f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
          this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
          this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
          this.world.makeSound(
              this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.d = false;
        }
      }

      if (this.d) {
        for (k = 0; k < 4; ++k) {
          this.world.a(
              "crit",
              this.locX + this.motX * (double) k / 4.0D,
              this.locY + this.motY * (double) k / 4.0D,
              this.locZ + this.motZ * (double) k / 4.0D,
              -this.motX,
              -this.motY + 0.2D,
              -this.motZ);
        }
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
      this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);

      for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D);
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f3 = 0.99F;

      f1 = 0.05F;
      if (this.az()) {
        for (int i1 = 0; i1 < 4; ++i1) {
          float f4 = 0.25F;

          this.world.a(
              "bubble",
              this.locX - this.motX * (double) f4,
              this.locY - this.motY * (double) f4,
              this.locZ - this.motZ * (double) f4,
              this.motX,
              this.motY,
              this.motZ);
        }

        f3 = 0.8F;
      }

      this.motX *= (double) f3;
      this.motY *= (double) f3;
      this.motZ *= (double) f3;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
    }
  }
Example #26
0
  private void g(World world, int i, int j, int k) {
    boolean flag = world.getData(i, j, k) == 1;
    boolean flag1 = false;
    float f = 0.125F;
    List list = null;

    if (this.a == EnumMobType.EVERYTHING) {
      list =
          world.b(
              (Entity) null,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (this.a == EnumMobType.MOBS) {
      list =
          world.a(
              EntityLiving.class,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (this.a == EnumMobType.PLAYERS) {
      list =
          world.a(
              EntityHuman.class,
              AxisAlignedBB.b(
                  (double) ((float) i + f),
                  (double) j,
                  (double) ((float) k + f),
                  (double) ((float) (i + 1) - f),
                  (double) j + 0.25D,
                  (double) ((float) (k + 1) - f)));
    }

    if (list.size() > 0) {
      flag1 = true;
    }

    // CraftBukkit start - Interact Pressure Plate
    org.bukkit.World bworld = world.getWorld();
    org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();

    if (flag != flag1) {
      if (flag1) {
        for (Object object : list) {
          if (object != null) {
            org.bukkit.event.Cancellable cancellable;

            if (object instanceof EntityHuman) {
              cancellable =
                  CraftEventFactory.callPlayerInteractEvent(
                      (EntityHuman) object,
                      org.bukkit.event.block.Action.PHYSICAL,
                      i,
                      j,
                      k,
                      -1,
                      null);
            } else if (object instanceof Entity) {
              cancellable =
                  new EntityInteractEvent(
                      ((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
              manager.callEvent((EntityInteractEvent) cancellable);
            } else {
              continue;
            }
            if (cancellable.isCancelled()) {
              return;
            }
          }
        }
      }

      BlockRedstoneEvent eventRedstone =
          new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
      manager.callEvent(eventRedstone);

      flag1 = eventRedstone.getNewCurrent() > 0;
    }
    // CraftBukkit end

    if (flag1 && !flag) {
      world.setData(i, j, k, 1);
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.b(i, j, k, i, j, k);
      world.makeSound(
          (double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag1 && flag) {
      world.setData(i, j, k, 0);
      world.applyPhysics(i, j, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.b(i, j, k, i, j, k);
      world.makeSound(
          (double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag1) {
      world.c(i, j, k, this.id, this.d());
    }
  }
Example #27
0
  public void l_() {
    super.l_();
    if (this.e() > 0) {
      this.a(this.e() - 1);
    }

    if (this.getDamage() > 0.0F) {
      this.setDamage(this.getDamage() - 1.0F);
    }

    this.lastX = this.locX;
    this.lastY = this.locY;
    this.lastZ = this.locZ;
    byte b0 = 5;
    double d0 = 0.0D;

    for (int i = 0; i < b0; ++i) {
      double d1 =
          this.boundingBox.b
              + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 0) / (double) b0
              - 0.125D;
      double d2 =
          this.boundingBox.b
              + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 1) / (double) b0
              - 0.125D;
      AxisAlignedBB axisalignedbb =
          AxisAlignedBB.a()
              .a(
                  this.boundingBox.a,
                  d1,
                  this.boundingBox.c,
                  this.boundingBox.d,
                  d2,
                  this.boundingBox.f);

      if (this.world.b(axisalignedbb, Material.WATER)) {
        d0 += 1.0D / (double) b0;
      }
    }

    double d3 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
    double d4;
    double d5;

    if (d3 > 0.26249999999999996D) {
      d4 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D);
      d5 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D);

      for (int j = 0; (double) j < 1.0D + d3 * 60.0D; ++j) {
        double d6 = (double) (this.random.nextFloat() * 2.0F - 1.0F);
        double d7 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D;
        double d8;
        double d9;

        if (this.random.nextBoolean()) {
          d8 = this.locX - d4 * d6 * 0.8D + d5 * d7;
          d9 = this.locZ - d5 * d6 * 0.8D - d4 * d7;
          this.world.addParticle(
              "splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ);
        } else {
          d8 = this.locX + d4 + d5 * d6 * 0.7D;
          d9 = this.locZ + d5 - d4 * d6 * 0.7D;
          this.world.addParticle(
              "splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ);
        }
      }
    }

    double d10;
    double d11;

    if (this.world.isStatic && this.a) {
      if (this.c > 0) {
        d4 = this.locX + (this.d - this.locX) / (double) this.c;
        d5 = this.locY + (this.e - this.locY) / (double) this.c;
        d10 = this.locZ + (this.f - this.locZ) / (double) this.c;
        d11 = MathHelper.g(this.g - (double) this.yaw);
        this.yaw = (float) ((double) this.yaw + d11 / (double) this.c);
        this.pitch =
            (float) ((double) this.pitch + (this.h - (double) this.pitch) / (double) this.c);
        --this.c;
        this.setPosition(d4, d5, d10);
        this.b(this.yaw, this.pitch);
      } else {
        d4 = this.locX + this.motX;
        d5 = this.locY + this.motY;
        d10 = this.locZ + this.motZ;
        this.setPosition(d4, d5, d10);
        if (this.onGround) {
          this.motX *= 0.5D;
          this.motY *= 0.5D;
          this.motZ *= 0.5D;
        }

        this.motX *= 0.9900000095367432D;
        this.motY *= 0.949999988079071D;
        this.motZ *= 0.9900000095367432D;
      }
    } else {
      if (d0 < 1.0D) {
        d4 = d0 * 2.0D - 1.0D;
        this.motY += 0.03999999910593033D * d4;
      } else {
        if (this.motY < 0.0D) {
          this.motY /= 2.0D;
        }

        this.motY += 0.007000000216066837D;
      }

      if (this.passenger != null && this.passenger instanceof EntityLiving) {
        d4 = (double) ((EntityLiving) this.passenger).bf;
        if (d4 > 0.0D) {
          d5 = -Math.sin((double) (this.passenger.yaw * 3.1415927F / 180.0F));
          d10 = Math.cos((double) (this.passenger.yaw * 3.1415927F / 180.0F));
          this.motX += d5 * this.b * 0.05000000074505806D;
          this.motZ += d10 * this.b * 0.05000000074505806D;
        }
      }

      d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      if (d4 > 0.35D) {
        d5 = 0.35D / d4;
        this.motX *= d5;
        this.motZ *= d5;
        d4 = 0.35D;
      }

      if (d4 > d3 && this.b < 0.35D) {
        this.b += (0.35D - this.b) / 35.0D;
        if (this.b > 0.35D) {
          this.b = 0.35D;
        }
      } else {
        this.b -= (this.b - 0.07D) / 35.0D;
        if (this.b < 0.07D) {
          this.b = 0.07D;
        }
      }

      if (this.onGround) {
        this.motX *= 0.5D;
        this.motY *= 0.5D;
        this.motZ *= 0.5D;
      }

      this.move(this.motX, this.motY, this.motZ);
      if (this.positionChanged && d3 > 0.2D) {
        if (!this.world.isStatic && !this.dead) {
          this.die();

          int k;

          for (k = 0; k < 3; ++k) {
            this.a(Block.WOOD.id, 1, 0.0F);
          }

          for (k = 0; k < 2; ++k) {
            this.a(Item.STICK.id, 1, 0.0F);
          }
        }
      } else {
        this.motX *= 0.9900000095367432D;
        this.motY *= 0.949999988079071D;
        this.motZ *= 0.9900000095367432D;
      }

      this.pitch = 0.0F;
      d5 = (double) this.yaw;
      d10 = this.lastX - this.locX;
      d11 = this.lastZ - this.locZ;
      if (d10 * d10 + d11 * d11 > 0.001D) {
        d5 = (double) ((float) (Math.atan2(d11, d10) * 180.0D / 3.141592653589793D));
      }

      double d12 = MathHelper.g(d5 - (double) this.yaw);

      if (d12 > 20.0D) {
        d12 = 20.0D;
      }

      if (d12 < -20.0D) {
        d12 = -20.0D;
      }

      this.yaw = (float) ((double) this.yaw + d12);
      this.b(this.yaw, this.pitch);
      if (!this.world.isStatic) {
        List list =
            this.world.getEntities(
                this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
        int l;

        if (list != null && !list.isEmpty()) {
          for (l = 0; l < list.size(); ++l) {
            Entity entity = (Entity) list.get(l);

            if (entity != this.passenger && entity.L() && entity instanceof EntityBoat) {
              entity.collide(this);
            }
          }
        }

        for (l = 0; l < 4; ++l) {
          int i1 = MathHelper.floor(this.locX + ((double) (l % 2) - 0.5D) * 0.8D);
          int j1 = MathHelper.floor(this.locZ + ((double) (l / 2) - 0.5D) * 0.8D);

          for (int k1 = 0; k1 < 2; ++k1) {
            int l1 = MathHelper.floor(this.locY) + k1;
            int i2 = this.world.getTypeId(i1, l1, j1);

            if (i2 == Block.SNOW.id) {
              this.world.setAir(i1, l1, j1);
            } else if (i2 == Block.WATER_LILY.id) {
              this.world.setAir(i1, l1, j1, true);
            }
          }
        }

        if (this.passenger != null && this.passenger.dead) {
          this.passenger = null;
        }
      }
    }
  }
Example #28
0
 public boolean r() {
   return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.f, this);
 }
  private void k(World world, int i, int j, int k) {
    int l = world.getData(i, j, k);
    boolean flag = (l & 1) == 1;
    boolean flag1 = false;
    List list =
        world.getEntities(
            (Entity) null,
            AxisAlignedBB.a()
                .a(
                    (double) i + this.minX,
                    (double) j + this.minY,
                    (double) k + this.minZ,
                    (double) i + this.maxX,
                    (double) j + this.maxY,
                    (double) k + this.maxZ));

    if (!list.isEmpty()) {
      Iterator iterator = list.iterator();

      while (iterator.hasNext()) {
        Entity entity = (Entity) iterator.next();

        if (!entity.at()) {
          flag1 = true;
          break;
        }
      }
    }

    // CraftBukkit start - Call interact even when triggering connected tripwire
    if (flag != flag1 && flag1 && (world.getData(i, j, k) & 4) == 4) {
      org.bukkit.World bworld = world.getWorld();
      org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
      org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
      boolean allowed = false;

      // If all of the events are cancelled block the tripwire trigger, else allow
      for (Object object : list) {
        if (object != null) {
          org.bukkit.event.Cancellable cancellable;

          if (object instanceof EntityHuman) {
            cancellable =
                org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(
                    (EntityHuman) object,
                    org.bukkit.event.block.Action.PHYSICAL,
                    i,
                    j,
                    k,
                    -1,
                    null);
          } else if (object instanceof Entity) {
            cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
            manager.callEvent((EntityInteractEvent) cancellable);
          } else {
            continue;
          }

          if (!cancellable.isCancelled()) {
            allowed = true;
            break;
          }
        }
      }

      if (!allowed) {
        return;
      }
    }
    // CraftBukkit end

    if (flag1 && !flag) {
      l |= 1;
    }

    if (!flag1 && flag) {
      l &= -2;
    }

    if (flag1 != flag) {
      world.setData(i, j, k, l, 3);
      this.d(world, i, j, k, l);
    }

    if (flag1) {
      world.a(i, j, k, this.id, this.a(world));
    }
  }
Example #30
0
  public void c(double d1, double d2, double d3) {
    if (T) {
      z.d(d1, d2, d3);
      p = (z.a + z.d) / 2D;
      q = (z.b + (double) H) - (double) R;
      r = (z.c + z.f) / 2D;
      return;
    }
    double d4 = p;
    double d5 = r;
    double d6 = d1;
    double d7 = d2;
    double d8 = d3;
    AxisAlignedBB axisalignedbb = z.b();
    boolean flag = A && p();

    if (flag) {
      double d9 = 0.050000000000000003D;

      for (; d1 != 0.0D && l.a(this, z.c(d1, -1D, 0.0D)).size() == 0; d6 = d1) {
        if (d1 < d9 && d1 >= -d9) {
          d1 = 0.0D;
          continue;
        }
        if (d1 > 0.0D) {
          d1 -= d9;
        } else {
          d1 += d9;
        }
      }

      for (; d3 != 0.0D && l.a(this, z.c(0.0D, -1D, d3)).size() == 0; d8 = d3) {
        if (d3 < d9 && d3 >= -d9) {
          d3 = 0.0D;
          continue;
        }
        if (d3 > 0.0D) {
          d3 -= d9;
        } else {
          d3 += d9;
        }
      }
    }
    List list = l.a(this, z.a(d1, d2, d3));

    for (int i1 = 0; i1 < list.size(); i1++) {
      d2 = ((AxisAlignedBB) list.get(i1)).b(z, d2);
    }

    z.d(0.0D, d2, 0.0D);
    if (!F && d7 != d2) {
      d1 = d2 = d3 = 0.0D;
    }
    boolean flag1 = A || d7 != d2 && d7 < 0.0D;

    for (int j1 = 0; j1 < list.size(); j1++) {
      d1 = ((AxisAlignedBB) list.get(j1)).a(z, d1);
    }

    z.d(d1, 0.0D, 0.0D);
    if (!F && d6 != d1) {
      d1 = d2 = d3 = 0.0D;
    }
    for (int k1 = 0; k1 < list.size(); k1++) {
      d3 = ((AxisAlignedBB) list.get(k1)).c(z, d3);
    }

    z.d(0.0D, 0.0D, d3);
    if (!F && d8 != d3) {
      d1 = d2 = d3 = 0.0D;
    }
    if (S > 0.0F && flag1 && R < 0.05F && (d6 != d1 || d8 != d3)) {
      double d10 = d1;
      double d12 = d2;
      double d14 = d3;

      d1 = d6;
      d2 = S;
      d3 = d8;
      AxisAlignedBB axisalignedbb1 = z.b();

      z.b(axisalignedbb);
      List list1 = l.a(this, z.a(d1, d2, d3));

      for (int j2 = 0; j2 < list1.size(); j2++) {
        d2 = ((AxisAlignedBB) list1.get(j2)).b(z, d2);
      }

      z.d(0.0D, d2, 0.0D);
      if (!F && d7 != d2) {
        d1 = d2 = d3 = 0.0D;
      }
      for (int k2 = 0; k2 < list1.size(); k2++) {
        d1 = ((AxisAlignedBB) list1.get(k2)).a(z, d1);
      }

      z.d(d1, 0.0D, 0.0D);
      if (!F && d6 != d1) {
        d1 = d2 = d3 = 0.0D;
      }
      for (int l2 = 0; l2 < list1.size(); l2++) {
        d3 = ((AxisAlignedBB) list1.get(l2)).c(z, d3);
      }

      z.d(0.0D, 0.0D, d3);
      if (!F && d8 != d3) {
        d1 = d2 = d3 = 0.0D;
      }
      if (d10 * d10 + d14 * d14 >= d1 * d1 + d3 * d3) {
        d1 = d10;
        d2 = d12;
        d3 = d14;
        z.b(axisalignedbb1);
      } else {
        R += 0.5D;
      }
    }
    p = (z.a + z.d) / 2D;
    q = (z.b + (double) H) - (double) R;
    r = (z.c + z.f) / 2D;
    B = d6 != d1 || d8 != d3;
    C = d7 != d2;
    A = d7 != d2 && d7 < 0.0D;
    D = B || C;
    a(d2, A);
    if (d6 != d1) {
      s = 0.0D;
    }
    if (d7 != d2) {
      t = 0.0D;
    }
    if (d8 != d3) {
      u = 0.0D;
    }
    double d11 = p - d4;
    double d13 = r - d5;

    if (M && !flag) {
      L += (double) MathHelper.a(d11 * d11 + d13 * d13) * 0.59999999999999998D;
      int k3 = MathHelper.b(p);
      int i4 = MathHelper.b(q - 0.20000000298023224D - (double) H);
      int l1 = MathHelper.b(r);
      int i3 = l.a(k3, i4, l1);

      if (L > (float) b && i3 > 0) {
        b++;
        StepSound stepsound = Block.m[i3].bq;

        if (l.a(k3, i4 + 1, l1) == Block.aS.bh) {
          stepsound = Block.aS.bq;
          l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
        } else if (!Block.m[i3].bs.d()) {
          l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
        }
        Block.m[i3].b(l, k3, i4, l1, this);
      }
    }
    int l3 = MathHelper.b(z.a);
    int j4 = MathHelper.b(z.b);
    int i2 = MathHelper.b(z.c);
    int j3 = MathHelper.b(z.d);
    int k4 = MathHelper.b(z.e);
    int l4 = MathHelper.b(z.f);

    for (int i5 = l3; i5 <= j3; i5++) {
      for (int j5 = j4; j5 <= k4; j5++) {
        for (int k5 = i2; k5 <= l4; k5++) {
          int l5 = l.a(i5, j5, k5);

          if (l5 > 0) {
            Block.m[l5].a(l, i5, j5, k5, this);
          }
        }
      }
    }

    R *= 0.4F;
    boolean flag2 = r();

    if (l.c(z)) {
      b(1);
      if (!flag2) {
        Z++;
        if (Z == 0) {
          Z = 300;
        }
      }
    } else if (Z <= 0) {
      Z = -Y;
    }
    if (flag2 && Z > 0) {
      l.a(this, "random.fizz", 0.7F, 1.6F + (W.nextFloat() - W.nextFloat()) * 0.4F);
      Z = -Y;
    }
  }