Ejemplo n.º 1
0
  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);
    }
  }
Ejemplo n.º 2
0
  public void a() {
    this.a.pitch = 0.0F;
    if (this.d) {
      this.d = false;
      double d0 = this.e - this.a.locX;
      double d1 = this.f - (this.a.locY + (double) this.a.getHeadHeight());
      double d2 = this.g - this.a.locZ;
      double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
      // CraftBukkit start - Math -> TrigMath
      float f = (float) (TrigMath.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
      float f1 = (float) (-(TrigMath.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
      // CraftBukkit end

      this.a.pitch = this.a(this.a.pitch, f1, this.c);
      this.a.as = this.a(this.a.as, f, this.b);
    } else {
      this.a.as = this.a(this.a.as, this.a.aq, 10.0F);
    }

    float f2 = MathHelper.g(this.a.as - this.a.aq);

    if (!this.a.getNavigation().f()) {
      if (f2 < -75.0F) {
        this.a.as = this.a.aq - 75.0F;
      }

      if (f2 > 75.0F) {
        this.a.as = this.a.aq + 75.0F;
      }
    }
  }
Ejemplo n.º 3
0
  public static WorldGenFlatInfo a(String s) {
    if (s == null) {
      return e();
    } else {
      String[] astring = s.split(";", -1);
      int i = astring.length == 1 ? 0 : MathHelper.a(astring[0], 0);

      if (i >= 0 && i <= 3) {
        WorldGenFlatInfo worldgenflatinfo = new WorldGenFlatInfo();
        int j = astring.length == 1 ? 0 : 1;
        List list = a(i, astring[j++]);

        if (list != null && !list.isEmpty()) {
          worldgenflatinfo.c().addAll(list);
          worldgenflatinfo.d();
          int k = BiomeBase.PLAINS.id;

          if (i > 0 && astring.length > j) {
            k = MathHelper.a(astring[j++], k);
          }

          worldgenflatinfo.a(k);
          if (i > 0 && astring.length > j) {
            String[] astring1 = astring[j++].toLowerCase().split(",");
            String[] astring2 = astring1;
            int l = astring1.length;

            for (int i1 = 0; i1 < l; ++i1) {
              String s1 = astring2[i1];
              String[] astring3 = s1.split("\\(", 2);
              HashMap hashmap = Maps.newHashMap();

              if (astring3[0].length() > 0) {
                worldgenflatinfo.b().put(astring3[0], hashmap);
                if (astring3.length > 1 && astring3[1].endsWith(")") && astring3[1].length() > 1) {
                  String[] astring4 = astring3[1].substring(0, astring3[1].length() - 1).split(" ");

                  for (int j1 = 0; j1 < astring4.length; ++j1) {
                    String[] astring5 = astring4[j1].split("=", 2);

                    if (astring5.length == 2) {
                      hashmap.put(astring5[0], astring5[1]);
                    }
                  }
                }
              }
            }
          } else {
            worldgenflatinfo.b().put("village", Maps.newHashMap());
          }

          return worldgenflatinfo;
        } else {
          return e();
        }
      } else {
        return e();
      }
    }
  }
Ejemplo n.º 4
0
  public void d(World world, BlockPosition blockposition) {
    if (!world.worldProvider.o()) {
      IBlockData iblockdata = world.getType(blockposition);
      int i = world.b(EnumSkyBlock.SKY, blockposition) - world.ab();
      float f = world.d(1.0F);
      float f1 = f < 3.1415927F ? 0.0F : 6.2831855F;

      f += (f1 - f) * 0.2F;
      i = Math.round((float) i * MathHelper.cos(f));
      i = MathHelper.clamp(i, 0, 15);
      if (this.b) {
        i = 15 - i;
      }

      if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) {
        i =
            org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(
                    world,
                    blockposition.getX(),
                    blockposition.getY(),
                    blockposition.getZ(),
                    ((Integer) iblockdata.get(POWER)),
                    i)
                .getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
        world.setTypeAndData(
            blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
      }
    }
  }
Ejemplo n.º 5
0
  @Override
  public void c() {
    if (this.world.v() && !this.world.isStatic) {
      float f = this.c(1.0F);

      if (f > 0.5F
          && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F
          && this.world.l(
              MathHelper.floor(this.locX),
              MathHelper.floor(this.locY),
              MathHelper.floor(this.locZ))) {
        ItemStack itemstack = this.getEquipment(4);

        if (itemstack != null) {
          if (itemstack.g()) {
            itemstack.setData(itemstack.j() + this.random.nextInt(2));
            if (itemstack.j() >= itemstack.l()) {
              this.a(itemstack);
              this.setEquipment(4, (ItemStack) null);
            }
          }
        }
      }
    }

    if (this.world.isStatic && this.getSkeletonType() == 1) {
      this.a(0.72F, 2.34F);
    }

    super.c();
  }
  public void m() {
    super.m();
    if (this.bs > 0) {
      --this.bs;
    }

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

    if (this.v * this.v + this.x * this.x > 2.500000277905201E-7D && this.random.nextInt(5) == 0) {
      int var1 = MathHelper.floor(this.s);
      int var2 = MathHelper.floor(this.t - 0.20000000298023224D);
      int var3 = MathHelper.floor(this.u);
      IBlockData var4 = this.o.getType(new BlockPosition(var1, var2, var3));
      Block var5 = var4.getBlock();
      if (var5.getMaterial() != Material.AIR) {
        this.o.a(
            class_cy.L,
            this.s + ((double) this.random.nextFloat() - 0.5D) * (double) this.J,
            this.aT().yMin + 0.1D,
            this.u + ((double) this.random.nextFloat() - 0.5D) * (double) this.J,
            4.0D * ((double) this.random.nextFloat() - 0.5D),
            0.5D,
            ((double) this.random.nextFloat() - 0.5D) * 4.0D,
            new int[] {Block.getCombinedId(var4)});
      }
    }
  }
Ejemplo n.º 7
0
  public void a(Entity entity, double d0, double d1, double d2, float f) {
    if (this.a.worldProvider.dimension != 1) {
      if (!this.b(entity, d0, d1, d2, f)) {
        this.a(entity);
        this.b(entity, d0, d1, d2, f);
      }
    } else {
      int i = MathHelper.floor(entity.locX);
      int j = MathHelper.floor(entity.locY) - 1;
      int k = MathHelper.floor(entity.locZ);
      byte b0 = 1;
      byte b1 = 0;

      for (int l = -2; l <= 2; ++l) {
        for (int i1 = -2; i1 <= 2; ++i1) {
          for (int j1 = -1; j1 < 3; ++j1) {
            int k1 = i + i1 * b0 + l * b1;
            int l1 = j + j1;
            int i2 = k + i1 * b1 - l * b0;
            boolean flag = j1 < 0;

            this.a.setTypeIdUpdate(k1, l1, i2, flag ? Block.OBSIDIAN.id : 0);
          }
        }
      }

      entity.setPositionRotation((double) i, (double) j, (double) k, entity.yaw, 0.0F);
      entity.motX = entity.motY = entity.motZ = 0.0D;
    }
  }
Ejemplo n.º 8
0
  public void d() {
    this.a = Math.max(0, this.a - 1);
    if (this.a == 4) {
      int i = MathHelper.floor(this.b.locX);
      int j = MathHelper.floor(this.b.locY);
      int k = MathHelper.floor(this.b.locZ);

      if (this.c.getTypeId(i, j, k) == Block.LONG_GRASS.id) {
        // CraftBukkit start
        if (!CraftEventFactory.callEntityChangeBlockEvent(
                this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR)
            .isCancelled()) {
          this.c.triggerEffect(2001, i, j, k, Block.LONG_GRASS.id + 4096);
          this.c.setTypeId(i, j, k, 0);
          this.b.aA();
        }
        // CraftBukkit end
      } else if (this.c.getTypeId(i, j - 1, k) == Block.GRASS.id) {
        // CraftBukkit start
        if (!CraftEventFactory.callEntityChangeBlockEvent(
                this.b.getBukkitEntity(),
                this.b.world.getWorld().getBlockAt(i, j - 1, k),
                Material.DIRT)
            .isCancelled()) {
          this.c.triggerEffect(2001, i, j - 1, k, Block.GRASS.id);
          this.c.setTypeId(i, j - 1, k, Block.DIRT.id);
          this.b.aA();
        }
        // CraftBukkit end
      }
    }
  }
Ejemplo n.º 9
0
  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);
  }
Ejemplo n.º 10
0
 public void appendEntityCrashDetails(CrashReportSystemDetails crashreportsystemdetails) {
   crashreportsystemdetails.a("Entity Type", (Callable) (new CrashReportEntityType(this)));
   crashreportsystemdetails.a("Entity ID", (Object) Integer.valueOf(this.id));
   crashreportsystemdetails.a("Entity Name", (Callable) (new CrashReportEntityName(this)));
   crashreportsystemdetails.a(
       "Entity\'s Exact location",
       (Object)
           String.format(
               "%.2f, %.2f, %.2f",
               new Object[] {
                 Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)
               }));
   crashreportsystemdetails.a(
       "Entity\'s Block location",
       (Object)
           CrashReportSystemDetails.a(
               (double) MathHelper.floor(this.locX),
               (double) MathHelper.floor(this.locY),
               (double) MathHelper.floor(this.locZ)));
   crashreportsystemdetails.a(
       "Entity\'s Momentum",
       (Object)
           String.format(
               "%.2f, %.2f, %.2f",
               new Object[] {
                 Double.valueOf(this.motX), Double.valueOf(this.motY), Double.valueOf(this.motZ)
               }));
   crashreportsystemdetails.a("Entity\'s Rider", (Callable) (new CrashReportEntityRider(this)));
   crashreportsystemdetails.a(
       "Entity\'s Vehicle", (Callable) (new CrashReportEntityVehicle(this)));
 }
Ejemplo n.º 11
0
  protected float f(float f, float f1) {
    float f2 = MathHelper.g(f - this.aN);

    this.aN += f2 * 0.3F;
    float f3 = MathHelper.g(this.yaw - this.aN);
    boolean flag = f3 < -90.0F || f3 >= 90.0F;

    if (f3 < -75.0F) {
      f3 = -75.0F;
    }

    if (f3 >= 75.0F) {
      f3 = 75.0F;
    }

    this.aN = this.yaw - f3;
    if (f3 * f3 > 2500.0F) {
      this.aN += f3 * 0.2F;
    }

    if (flag) {
      f1 *= -1.0F;
    }

    return f1;
  }
Ejemplo n.º 12
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;
  }
Ejemplo n.º 13
0
  public void collide(Entity entity) {
    if (entity.passenger != this && entity.vehicle != this) {
      if (!entity.T && !this.T) {
        double d0 = entity.locX - this.locX;
        double d1 = entity.locZ - this.locZ;
        double d2 = MathHelper.a(d0, d1);

        if (d2 >= 0.009999999776482582D) {
          d2 = (double) MathHelper.sqrt(d2);
          d0 /= d2;
          d1 /= d2;
          double d3 = 1.0D / d2;

          if (d3 > 1.0D) {
            d3 = 1.0D;
          }

          d0 *= d3;
          d1 *= d3;
          d0 *= 0.05000000074505806D;
          d1 *= 0.05000000074505806D;
          d0 *= (double) (1.0F - this.U);
          d1 *= (double) (1.0F - this.U);
          if (this.passenger == null) {
            this.g(-d0, 0.0D, -d1);
          }

          if (entity.passenger == null) {
            entity.g(d0, 0.0D, d1);
          }
        }
      }
    }
  }
Ejemplo n.º 14
0
  public void c() {
    super.c();
    if (this.br > 0) {
      --this.br;
    }

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

    if (this.motX * this.motX + this.motZ * this.motZ > 2.500000277905201E-7D
        && this.random.nextInt(5) == 0) {
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
      int k = MathHelper.floor(this.locZ);
      int l = this.world.getTypeId(i, j, k);

      if (l > 0) {
        this.world.addParticle(
            "tilecrack_" + l + "_" + this.world.getData(i, j, k),
            this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width,
            this.boundingBox.b + 0.1D,
            this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width,
            4.0D * ((double) this.random.nextFloat() - 0.5D),
            0.5D,
            ((double) this.random.nextFloat() - 0.5D) * 4.0D);
      }
    }
  }
Ejemplo n.º 15
0
  public void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    NBTTagList nbttaglist = nbttagcompound.getList("Inventory");

    this.inventory.b(nbttaglist);
    this.dimension = nbttagcompound.getInt("Dimension");
    this.sleeping = nbttagcompound.getBoolean("Sleeping");
    this.sleepTicks = nbttagcompound.getShort("SleepTimer");
    this.exp = nbttagcompound.getFloat("XpP");
    this.expLevel = nbttagcompound.getInt("XpLevel");
    this.expTotal = nbttagcompound.getInt("XpTotal");
    if (this.sleeping) {
      this.F =
          new ChunkCoordinates(
              MathHelper.floor(this.locX),
              MathHelper.floor(this.locY),
              MathHelper.floor(this.locZ));
      this.a(true, true, false);
    }

    if (nbttagcompound.hasKey("SpawnX")
        && nbttagcompound.hasKey("SpawnY")
        && nbttagcompound.hasKey("SpawnZ")) {
      this.b =
          new ChunkCoordinates(
              nbttagcompound.getInt("SpawnX"),
              nbttagcompound.getInt("SpawnY"),
              nbttagcompound.getInt("SpawnZ"));
    }

    this.foodData.a(nbttagcompound);
    this.abilities.b(nbttagcompound);
  }
Ejemplo n.º 16
0
  protected void a(double d0, boolean flag) {
    if (!this.H()) {
      this.I();
    }

    if (flag && this.fallDistance > 0.0F) {
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
      int k = MathHelper.floor(this.locZ);
      int l = this.world.getTypeId(i, j, k);

      if (l == 0) {
        int i1 = this.world.e(i, j - 1, k);

        if (i1 == 11 || i1 == 32 || i1 == 21) {
          l = this.world.getTypeId(i, j - 1, k);
        }
      }

      if (l > 0) {
        Block.byId[l].a(this.world, i, j, k, this, this.fallDistance);
      }
    }

    super.a(d0, flag);
  }
Ejemplo n.º 17
0
  public boolean cr() {
    int i = MathHelper.floor(this.locX);
    int j = MathHelper.floor(this.locZ);

    this.world.getBiome(i, j);
    return true;
  }
Ejemplo n.º 18
0
  public void shoot(double d0, double d1, double d2, float f, float f1) {
    float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);

    d0 /= (double) f2;
    d1 /= (double) f2;
    d2 /= (double) f2;
    d0 +=
        this.random.nextGaussian()
            * (double) (this.random.nextBoolean() ? -1 : 1)
            * 0.007499999832361937D
            * (double) f1;
    d1 +=
        this.random.nextGaussian()
            * (double) (this.random.nextBoolean() ? -1 : 1)
            * 0.007499999832361937D
            * (double) f1;
    d2 +=
        this.random.nextGaussian()
            * (double) (this.random.nextBoolean() ? -1 : 1)
            * 0.007499999832361937D
            * (double) f1;
    d0 *= (double) f;
    d1 *= (double) f;
    d2 *= (double) f;
    this.motX = d0;
    this.motY = d1;
    this.motZ = d2;
    float f3 = MathHelper.sqrt(d0 * d0 + d2 * d2);

    this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
    this.lastPitch =
        this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
    this.at = 0;
  }
Ejemplo n.º 19
0
  protected void a(double d0, boolean flag) {
    if (!this.M()) {
      this.N();
    }

    if (flag && this.fallDistance > 0.0F) {
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
      int k = MathHelper.floor(this.locZ);
      Block block = this.world.getType(i, j, k);

      if (block.getMaterial() == Material.AIR) {
        int l = this.world.getType(i, j - 1, k).b();

        if (l == 11 || l == 32 || l == 21) {
          block = this.world.getType(i, j - 1, k);
        }
      } else if (!this.world.isStatic && this.fallDistance > 3.0F) {
        this.world.triggerEffect(2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F));
      }

      block.a(this.world, i, j, k, this, this.fallDistance);
    }

    super.a(d0, flag);
  }
Ejemplo n.º 20
0
  public boolean e() {
    int i = MathHelper.floor(this.locX);
    int j = MathHelper.floor(this.boundingBox.b);
    int k = MathHelper.floor(this.locZ);
    int l = this.world.getTypeId(i, j, k);

    return l == Block.LADDER.id || l == Block.VINE.id;
  }
Ejemplo n.º 21
0
  protected final Vec3D f(float f, float f1) {
    float f2 = MathHelper.cos(-f1 * 0.017453292F - 3.1415927F);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - 3.1415927F);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);

    return new Vec3D((double) (f3 * f4), (double) f5, (double) (f2 * f4));
  }
Ejemplo n.º 22
0
  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);
  }
Ejemplo n.º 23
0
  public boolean h_() {
    int i = MathHelper.floor(this.locX);
    int j = MathHelper.floor(this.boundingBox.b);
    int k = MathHelper.floor(this.locZ);
    Block block = this.world.getType(i, j, k);

    return block == Blocks.LADDER || block == Blocks.VINE;
  }
Ejemplo n.º 24
0
  public boolean canSpawn() {
    int i = MathHelper.floor(this.locX);
    int j = MathHelper.floor(this.boundingBox.b);
    int k = MathHelper.floor(this.locZ);

    return this.world.getTypeId(i, j - 1, k) == Block.GRASS.id
        && this.world.l(i, j, k) > 8
        && super.canSpawn();
  }
Ejemplo n.º 25
0
 private Vec3D f() {
   Random localRandom = this.a.au();
   for (int i = 0; i < 10; i++) {
     int j = MathHelper.floor(this.a.locX + localRandom.nextInt(20) - 10.0D);
     int k = MathHelper.floor(this.a.boundingBox.b + localRandom.nextInt(6) - 3.0D);
     int m = MathHelper.floor(this.a.locZ + localRandom.nextInt(20) - 10.0D);
     if ((!this.f.j(j, k, m)) && (this.a.a(j, k, m) < 0.0F)) return Vec3D.a().create(j, k, m);
   }
   return null;
 }
Ejemplo n.º 26
0
  public EntityWeatherLighting(World world, double d0, double d1, double d2) {
    super(world);
    this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
    this.lifeTicks = 2;
    this.a = this.random.nextLong();
    this.c = this.random.nextInt(3) + 1;
    if (world.difficulty >= 2
        && world.areChunksLoaded(
            MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) {
      int i = MathHelper.floor(d0);
      int j = MathHelper.floor(d1);
      int k = MathHelper.floor(d2);

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

      for (i = 0; i < 4; ++i) {
        j = MathHelper.floor(d0) + this.random.nextInt(3) - 1;
        k = MathHelper.floor(d1) + this.random.nextInt(3) - 1;
        int l = MathHelper.floor(d2) + this.random.nextInt(3) - 1;

        if (world.getTypeId(j, k, l) == 0 && Block.FIRE.canPlace(world, j, k, l)) {
          world.setTypeId(j, k, l, Block.FIRE.id);
        }
      }
    }
  }
Ejemplo n.º 27
0
  public void b(float f) {
    float f1 = MathHelper.cos(f);
    float f2 = MathHelper.sin(f);
    double d0 = this.a * (double) f1 + this.c * (double) f2;
    double d1 = this.b;
    double d2 = this.c * (double) f1 - this.a * (double) f2;

    this.a = d0;
    this.b = d1;
    this.c = d2;
  }
Ejemplo n.º 28
0
  protected void b(float f) {
    if (f > 1.0F) {
      this.makeSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.f(f * 0.5F - 3.0F);

    if (i > 0) {
      // CraftBukkit start - fire EntityDamageEvent
      EntityDamageEvent event =
          CraftEventFactory.callEntityDamageEvent(
              null, this, EntityDamageEvent.DamageCause.FALL, i);
      if (!event.isCancelled()) {
        float damage = (float) event.getDamage();
        if (damage > 0) {
          this.getBukkitEntity().setLastDamageCause(event);
          this.damageEntity(DamageSource.FALL, damage);
        }
      }

      if (this.passenger != null) {
        EntityDamageEvent passengerEvent =
            CraftEventFactory.callEntityDamageEvent(
                null, this.passenger, EntityDamageEvent.DamageCause.FALL, i);
        if (!passengerEvent.isCancelled()
            && this.passenger != null) { // Check again in case of plugin
          float damage = (float) passengerEvent.getDamage();
          if (damage > 0) {
            this.passenger.getBukkitEntity().setLastDamageCause(passengerEvent);
            this.passenger.damageEntity(DamageSource.FALL, damage);
          }
        }
        // CraftBukkit end
      }

      Block block =
          this.world.getType(
              MathHelper.floor(this.locX),
              MathHelper.floor(this.locY - 0.2D - (double) this.lastYaw),
              MathHelper.floor(this.locZ));

      if (block.getMaterial() != Material.AIR) {
        StepSound stepsound = block.stepSound;

        this.world.makeSound(
            this,
            stepsound.getStepSound(),
            stepsound.getVolume1() * 0.5F,
            stepsound.getVolume2() * 0.75F);
      }
    }
  }
Ejemplo n.º 29
0
  public Vec3D k(double var1, double var3, double var5) {
    int var7 = MathHelper.floor(var1);
    int var8 = MathHelper.floor(var3);
    int var9 = MathHelper.floor(var5);
    if (BlockMinecartTrackAbstract.e(this.world, new BlockPosition(var7, var8 - 1, var9))) {
      --var8;
    }

    IBlockData var10 = this.world.getType(new BlockPosition(var7, var8, var9));
    if (BlockMinecartTrackAbstract.d(var10)) {
      BlockMinecartTrackAbstract.EnumTrackPosition var11 =
          (BlockMinecartTrackAbstract.EnumTrackPosition)
              var10.get(((BlockMinecartTrackAbstract) var10.getBlock()).n());
      int[][] var12 = matrix[var11.a()];
      double var13 = 0.0D;
      double var15 = (double) var7 + 0.5D + (double) var12[0][0] * 0.5D;
      double var17 = (double) var8 + 0.0625D + (double) var12[0][1] * 0.5D;
      double var19 = (double) var9 + 0.5D + (double) var12[0][2] * 0.5D;
      double var21 = (double) var7 + 0.5D + (double) var12[1][0] * 0.5D;
      double var23 = (double) var8 + 0.0625D + (double) var12[1][1] * 0.5D;
      double var25 = (double) var9 + 0.5D + (double) var12[1][2] * 0.5D;
      double var27 = var21 - var15;
      double var29 = (var23 - var17) * 2.0D;
      double var31 = var25 - var19;
      if (var27 == 0.0D) {
        var1 = (double) var7 + 0.5D;
        var13 = var5 - (double) var9;
      } else if (var31 == 0.0D) {
        var5 = (double) var9 + 0.5D;
        var13 = var1 - (double) var7;
      } else {
        double var33 = var1 - var15;
        double var35 = var5 - var19;
        var13 = (var33 * var27 + var35 * var31) * 2.0D;
      }

      var1 = var15 + var27 * var13;
      var3 = var17 + var29 * var13;
      var5 = var19 + var31 * var13;
      if (var29 < 0.0D) {
        ++var3;
      }

      if (var29 > 0.0D) {
        var3 += 0.5D;
      }

      return new Vec3D(var1, var3, var5);
    } else {
      return null;
    }
  }
Ejemplo n.º 30
0
  public boolean a() {
    if (this.b.au().nextInt(this.b.isBaby() ? 50 : 1000) != 0) {
      return false;
    } else {
      int i = MathHelper.floor(this.b.locX);
      int j = MathHelper.floor(this.b.locY);
      int k = MathHelper.floor(this.b.locZ);

      return this.c.getTypeId(i, j, k) == Block.LONG_GRASS.id && this.c.getData(i, j, k) == 1
          ? true
          : this.c.getTypeId(i, j - 1, k) == Block.GRASS.id;
    }
  }