Exemplo n.º 1
0
 public boolean teleport(Location location, TeleportCause cause) {
   entity.world = ((CraftWorld) location.getWorld()).getHandle();
   entity.setLocation(
       location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
   // entity.setLocation() throws no event, and so cannot be cancelled
   return true;
 }
Exemplo n.º 2
0
  public void b(World var1, BlockPosition var2, IBlockData var3, Random var4) {
    super.b(var1, var2, var3, var4);
    if (var1.worldProvider.d()
        && var1.getGameRules().getBoolean("doMobSpawning")
        && var4.nextInt(2000) < var1.getDifficulty().a()) {
      int var5 = var2.getY();

      BlockPosition var6;
      for (var6 = var2;
          !World.a((IBlockAccess) var1, (BlockPosition) var6) && var6.getY() > 0;
          var6 = var6.down()) {;
      }

      if (var5 > 0 && !var1.getType(var6.up()).getBlock().isOccluding()) {
        Entity var7 =
            ItemMonsterEgg.a(
                var1,
                57,
                (double) var6.getX() + 0.5D,
                (double) var6.getY() + 1.1D,
                (double) var6.getZ() + 0.5D);
        if (var7 != null) {
          var7.portalCooldown = var7.aq();
        }
      }
    }
  }
Exemplo n.º 3
0
  public void onEntityDamage(EntityDamageEvent event) {
    if (event instanceof EntityDamageByEntityEvent
        || event instanceof EntityDamageByProjectileEvent) {
      handlerAttackDefend((EntityDamageByEntityEvent) event);
    } else if (event.getCause() == DamageCause.FIRE_TICK) {
      Entity entity = event.getEntity();
      if (entity instanceof Player) {
        Player player = (Player) entity;
        Team team = war.getPlayerTeam(player.getName());
        if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
          // smother out the fire that didn't burn out when you respawned
          // Stop fire (upcast, watch out!)
          if (player instanceof CraftPlayer) {
            net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle();
            playerEntity.fireTicks = 0;
          }
          event.setCancelled(true);
        }
      }

    } else if (event.getCause() == DamageCause.DROWNING) {
      Entity entity = event.getEntity();
      if (entity instanceof Player) {
        Player player = (Player) entity;
        Team team = war.getPlayerTeam(player.getName());
        if (team != null && player.getHealth() <= 0) {
          // don't keep killing drowing player: trying to stop "Player moved wrongly!" error at
          // respawn.
          event.setCancelled(true);
        }
      }
    }
  }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
  private void a(float f, float f1) {
    if (this.k) {
      f = 1.0F - f;
    } else {
      --f;
    }

    AxisAlignedBB axisalignedbb =
        Blocks.PISTON_MOVING.a(this.world, this.x, this.y, this.z, this.a, f, this.j);

    if (axisalignedbb != null) {
      List list = this.world.getEntities((Entity) null, axisalignedbb);

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

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

          entity.move(
              (double) (f1 * (float) Facing.b[this.j]),
              (double) (f1 * (float) Facing.c[this.j]),
              (double) (f1 * (float) Facing.d[this.j]));
        }

        this.o.clear();
      }
    }
  }
Exemplo n.º 6
0
  public void a(Packet7UseEntity packet7useentity) {
    // CraftBukkit start
    if (this.player.dead) {
      return;
    }
    // CraftBukkit end

    WorldServer worldserver = this.minecraftServer.a(this.player.dimension);
    Entity entity = worldserver.getEntity(packet7useentity.target);

    if (entity != null && this.player.e(entity) && this.player.g(entity) < 36.0D) {
      if (packet7useentity.c == 0) {
        // CraftBukkit start
        PlayerInteractEntityEvent piee =
            new PlayerInteractEntityEvent((Player) getPlayer(), entity.getBukkitEntity());
        server.getPluginManager().callEvent(piee);
        if (piee.isCancelled()) {
          return;
        }
        // CraftBukkit end
        this.player.c(entity);
      } else if (packet7useentity.c == 1) {
        this.player.d(entity);
      }
    }
  }
Exemplo n.º 7
0
  public void die(DamageSource damagesource) {
    Entity entity = damagesource.getEntity();
    EntityLiving entityliving = this.aX();

    if (this.bb >= 0 && entityliving != null) {
      entityliving.b(this, this.bb);
    }

    if (entity != null) {
      entity.a(this);
    }

    this.aU = true;
    if (!this.world.isStatic) {
      int i = 0;

      if (entity instanceof EntityHuman) {
        i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel((EntityLiving) entity);
      }

      if (this.aG() && this.world.getGameRules().getBoolean("doMobLoot")) {
        this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i);
        this.dropEquipment(this.lastDamageByPlayerTime > 0, i);
        if (this.lastDamageByPlayerTime > 0) {
          int j = this.random.nextInt(200) - i;

          if (j < 5) {
            this.getRareDrop(j <= 0 ? 1 : 0);
          }
        }
      }
    }

    this.world.broadcastEntityEffect(this, (byte) 3);
  }
Exemplo n.º 8
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;
    }
  }
Exemplo n.º 9
0
  public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
    @SuppressWarnings("unchecked")
    List<Entity> notchEntityList =
        entity.world.getEntities(entity, entity.boundingBox.grow(x, y, z));
    List<org.bukkit.entity.Entity> bukkitEntityList =
        new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());

    for (Entity e : notchEntityList) {
      bukkitEntityList.add(e.getBukkitEntity());
    }
    return bukkitEntityList;
  }
Exemplo n.º 10
0
  public boolean m(Entity entity) {
    this.br = 10;
    this.world.broadcastEntityEffect(this, (byte) 4);
    boolean flag =
        entity.damageEntity(DamageSource.mobAttack(this), (float) (7 + this.random.nextInt(15)));

    if (flag) {
      entity.motY += 0.4000000059604645D;
    }

    this.makeSound("mob.irongolem.throw", 1.0F, 1.0F);
    return flag;
  }
  public boolean r(Entity var1) {
    this.bs = 10;
    this.o.a((Entity) this, (byte) 4);
    boolean var2 =
        var1.damageEntity(
            DamageSource.a((EntityLiving) this), (float) (7 + this.random.nextInt(15)));
    if (var2) {
      var1.motY += 0.4000000059604645D;
      this.a(this, var1);
    }

    this.a("mob.irongolem.throw", 1.0F, 1.0F);
    return var2;
  }
Exemplo n.º 12
0
  protected void bo() {
    List list =
        this.world.getEntities(
            this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));

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

        if (entity.S()) {
          this.n(entity);
        }
      }
    }
  }
Exemplo n.º 13
0
  public boolean strikeLightning(Entity entity) {
    // CraftBukkit start
    LightningStrikeEvent lightning =
        new LightningStrikeEvent(
            this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
    this.getServer().getPluginManager().callEvent(lightning);

    if (lightning.isCancelled()) {
      return false;
    }

    if (super.strikeLightning(entity)) {
      this.server
          .getPlayerList()
          .sendPacketNearby(
              entity.locX,
              entity.locY,
              entity.locZ,
              512.0D,
              this.dimension,
              new Packet71Weather(entity));
      // CraftBukkit end
      return true;
    } else {
      return false;
    }
  }
Exemplo n.º 14
0
  public void mount(Entity entity) {
    this.ap = 0.0D;
    this.aq = 0.0D;
    if (entity == null) {
      if (this.vehicle != null) {
        this.setPositionRotation(
            this.vehicle.locX,
            this.vehicle.getBoundingBox().b + (double) this.vehicle.length,
            this.vehicle.locZ,
            this.yaw,
            this.pitch);
        this.vehicle.passenger = null;
      }

      this.vehicle = null;
    } else {
      if (this.vehicle != null) {
        this.vehicle.passenger = null;
      }

      if (entity != null) {
        for (Entity entity1 = entity.vehicle; entity1 != null; entity1 = entity1.vehicle) {
          if (entity1 == this) {
            return;
          }
        }
      }

      this.vehicle = entity;
      entity.passenger = this;
    }
  }
Exemplo n.º 15
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);
          }
        }
      }
    }
  }
Exemplo n.º 16
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);
    }
  }
Exemplo n.º 17
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);
  }
Exemplo n.º 18
0
 public void onEntityCombust(EntityCombustEvent event) {
   Entity entity = event.getEntity();
   if (entity instanceof Player) {
     Player player = (Player) entity;
     Team team = war.getPlayerTeam(player.getName());
     if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
       // smother out the fire that didn't burn out when you respawned
       // Stop fire (upcast, watch out!)
       if (player instanceof CraftPlayer) {
         net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle();
         playerEntity.fireTicks = 0;
       }
       event.setCancelled(true);
     }
   }
 }
Exemplo n.º 19
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);
  }
Exemplo n.º 20
0
 /**
  * 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;
 }
Exemplo n.º 21
0
  public void n(Entity entity) {
    NBTTagCompound nbttagcompound = new NBTTagCompound();

    entity.e(nbttagcompound);
    this.f(nbttagcompound);
    this.portalCooldown = entity.portalCooldown;
    this.an = entity.an;
  }
Exemplo n.º 22
0
  public void receive(Entity entity, int i) {
    if (!entity.dead && !this.world.isStatic) {
      EntityTracker entitytracker = ((WorldServer) this.world).getTracker();

      if (entity instanceof EntityItem) {
        entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId())));
      }

      if (entity instanceof EntityArrow) {
        entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId())));
      }

      if (entity instanceof EntityExperienceOrb) {
        entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId())));
      }
    }
  }
Exemplo n.º 23
0
  protected EntityHorse a(Entity entity, double d0) {
    double d1 = Double.MAX_VALUE;
    Entity entity1 = null;
    List list = this.world.getEntities(entity, entity.boundingBox.a(d0, d0, d0), bu);
    Iterator iterator = list.iterator();

    while (iterator.hasNext()) {
      Entity entity2 = (Entity) iterator.next();
      double d2 = entity2.e(entity.locX, entity.locY, entity.locZ);

      if (d2 < d1) {
        entity1 = entity2;
        d1 = d2;
      }
    }

    return (EntityHorse) entity1;
  }
Exemplo n.º 24
0
  public void a(World world, int i, int j, int k, Random random) {
    super.a(world, i, j, k, random);
    if (world.worldProvider.d() && random.nextInt(2000) < world.difficulty) {
      int l;

      for (l = j; !world.w(i, l, k) && l > 0; --l) {;
      }

      if (l > 0 && !world.u(i, l + 1, k)) {
        Entity entity =
            ItemMonsterEgg.a(world, 57, (double) i + 0.5D, (double) l + 1.1D, (double) k + 0.5D);

        if (entity != null) {
          entity.portalCooldown = entity.aa();
        }
      }
    }
  }
Exemplo n.º 25
0
 /**
  * Checks if the minecart is added to the world. If not, returns false and removes the minecart
  *
  * @param minecart to check (only checks if it is an EntityMinecart)
  * @return True if valid, False if not
  */
 public static boolean validateMinecart(net.minecraft.server.Entity minecart) {
   if (minecart instanceof EntityMinecart) {
     // could be a bugged minecart.
     // verify that it is not bugged
     if (!minecart.world.entityList.contains(minecart)) {
       // bugged minecart - kill it!
       minecart.dead = true;
       minecart.world.removeEntity(minecart);
       minecart.ah = MathUtil.locToChunk(minecart.locX);
       minecart.ai = MathUtil.locToChunk(minecart.locY);
       minecart.aj = MathUtil.locToChunk(minecart.locZ);
       if (minecart.world.chunkProvider.isChunkLoaded(minecart.ah, minecart.aj)) {
         minecart.world.getChunkAt(minecart.ah, minecart.aj).b(minecart);
       }
       return false;
     }
   }
   return true;
 }
Exemplo n.º 26
0
 public boolean o(Entity entity) {
   return this.world.a(
           this.world
               .getVec3DPool()
               .create(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ),
           this.world
               .getVec3DPool()
               .create(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ))
       == null;
 }
Exemplo n.º 27
0
  protected void b(Entity entity) {
    super.b(entity);
    this.entitiesById.d(entity.id);
    Entity[] aentity = entity.ao();

    if (aentity != null) {
      for (int i = 0; i < aentity.length; ++i) {
        this.entitiesById.d(aentity[i].id);
      }
    }
  }
Exemplo n.º 28
0
 public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) {
   this.tracker = entity;
   this.b = i;
   this.c = j;
   this.isMoving = flag;
   this.xLoc = MathHelper.floor(entity.locX * 32.0D);
   this.yLoc = MathHelper.floor(entity.locY * 32.0D);
   this.zLoc = MathHelper.floor(entity.locZ * 32.0D);
   this.yRot = MathHelper.d(entity.yaw * 256.0F / 360.0F);
   this.xRot = MathHelper.d(entity.pitch * 256.0F / 360.0F);
   this.i = MathHelper.d(entity.am() * 256.0F / 360.0F);
 }
Exemplo n.º 29
0
  public void setSprinting(boolean flag) {
    super.setSprinting(flag);
    AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d);

    if (attributeinstance.a(b) != null) {
      attributeinstance.b(c);
    }

    if (flag) {
      attributeinstance.a(c);
    }
  }
Exemplo n.º 30
0
  public void a(Entity entity, float f, float f1) {
    this.e = entity.locX;
    if (entity instanceof EntityLiving) {
      this.f = entity.locY + (double) entity.getHeadHeight();
    } else {
      this.f = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D;
    }

    this.g = entity.locZ;
    this.b = f;
    this.c = f1;
    this.d = true;
  }