Package org.bukkit.entity

Examples of org.bukkit.entity.Entity


            // Load the chunk this minecart is in and remove it
            // We already de-linked the group map, so no worry for replacements
            Chunk chunk = world.getChunkAt(wm.cx, wm.cz);
            Iterator<Entity> iter = WorldUtil.getEntities(chunk).iterator();
            while (iter.hasNext()) {
              Entity next = iter.next();
              if (next.getUniqueId().equals(wm.entityUID)) {
                next.remove();
              }
            }
          }
        }
      }
View Full Code Here


    // Try to find it in the world
    if (mm == null) {
      // Load a 5x5 chunk area around this Minecart so it can properly be found
      WorldUtil.loadChunks(world, this.cx, this.cz, 2);
      // Try to find it
      Entity e = EntityUtil.getEntity(world, this.entityUID);
      if (e instanceof Minecart) {
        mm = MinecartMemberStore.convert((Minecart) e);
      }
    }
    // Restore velocity
View Full Code Here

    }
    Location mloc = mm.getEntity().getLocation();
    mloc.setYaw(FaceUtil.faceToYaw(mm.getDirection()));
    mloc.setPitch(0.0f);
    final Location loc = MathUtil.move(mloc, mm.getProperties().exitOffset);
    final Entity e = event.getExited();
    //teleport
    CommonUtil.nextTick(new Runnable() {
      public void run() {
        if (e.isDead()) {
          return;
        }
        loc.setYaw(e.getLocation().getYaw());
        loc.setPitch(e.getLocation().getPitch());
        e.teleport(loc);
      }
    });
    mm.resetCollisionEnter();
    mm.onPropertiesChanged();
  }
View Full Code Here

  public void onVehicleDamage(VehicleDamageEvent event) {
    MinecartMember<?> mm = MinecartMemberStore.get(event.getVehicle());
    if (mm == null) {
      return;
    }
    Entity attacker = event.getAttacker();
    if (attacker instanceof Projectile) {
      attacker = ((Projectile) attacker).getShooter();
    }
    if(attacker instanceof Player && Permission.BREAK_MINECART_ANY.has((Player) attacker)) {
      return;
View Full Code Here

  }

  @Override
  public void onPhysicsPostMove(double speedFactor) throws MemberMissingException, GroupUnloadedException {
    super.onPhysicsPostMove(speedFactor);
    Entity currentPassenger = entity.getPassenger();
    if (oldPassenger != currentPassenger) {
      // This was a temporary hotfix for the passengers teleporting out of minecarts all the time
      // This bug is now fixed, and thus this hotfix is no longer needed
      // In case of re-occurance, uncomment this piece of code
      // Note: this DOES cause plugins like Lift and LaunchMe to fail! (they replace network controllers too)
View Full Code Here


        // Check if the entity has been killed by another entity
        if (event instanceof EntityDamageByEntityEvent)
        {
            Entity killerEntity = ((EntityDamageByEntityEvent) event).getDamager();
            context.put("killer", new dEntity(killerEntity));

            // Check if the damager was a player and, if so, attach
            // that player to the action's ScriptEntry
            if (killerEntity instanceof Player)
                player = dPlayer.mirrorBukkitPlayer((Player) killerEntity);

                // If the damager was a projectile, take its shooter into
                // account as well
            else if (killerEntity instanceof Projectile)
            {
                ProjectileSource shooter = ((Projectile) killerEntity).getShooter();
                if (shooter != null && shooter instanceof LivingEntity) {

                    context.put("shooter", new dEntity((LivingEntity) shooter));
                    if (shooter instanceof Player)
                        player = dPlayer.mirrorBukkitPlayer((Player) shooter);

                    DenizenAPI.getDenizenNPC(npc).action("death by " +
                            ((LivingEntity) shooter).getType().toString(), player, context);
                }
                // TODO: Handle other shooter source thingy types
            }

            DenizenAPI.getDenizenNPC(npc).action("death by entity", player, context);
            DenizenAPI.getDenizenNPC(npc).action("death by " +
                    killerEntity.getType().toString(), player, context);

        }
        // If not, check if the entity has been killed by a block
        else if (event instanceof EntityDamageByBlockEvent)
        {
View Full Code Here

        // Get objects
        List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
        dEntity holder = null;
        dLocation holderLoc = null;
        Entity Holder = null;
        Object holderObject = scriptEntry.getObject("holder");
        if (holderObject instanceof dEntity) {
            holder = (dEntity) scriptEntry.getObject("holder");
            Holder = holder.getBukkitEntity();
        }
View Full Code Here

            // Go no further if we are dismounting entities
            return;
        }

        // Get the last entity on the list
        final Entity entity = entities.get(entities.size() - 1).getBukkitEntity();
        final LivingEntity finalController = controller != null ? controller.getLivingEntity() : null;

        BukkitRunnable task = new BukkitRunnable() {

            Location location = null;
            Boolean flying = true;

            public void run() {

                if (freeflight) {

                    // If freeflight is on, and the flying entity
                    // is ridden by another entity, let it keep
                    // flying where the controller is looking

                    if (!entity.isEmpty() && finalController.isInsideVehicle()) {
                        location = finalController.getEyeLocation()
                                     .add(finalController.getEyeLocation().getDirection()
                                     .multiply(30));
                    }
                    else {
                        flying = false;
                    }
                }
                else {

                    // If freelight is not on, keep flying only as long
                    // as there are destinations left

                    if (destinations.size() > 0) {
                        location = destinations.get(0);
                    }
                    else {
                        flying = false;
                    }
                }

                if (flying && entity.isValid()) {

                    // To avoid excessive turbulence, only have the entity rotate
                    // when it really needs to
                    if (!Rotation.isFacingLocation(entity, location, rotationThreshold)) {

                        Rotation.faceLocation(entity, location);
                    }

                    Vector v1 = entity.getLocation().toVector();
                    Vector v2 = location.toVector();
                    Vector v3 = v2.clone().subtract(v1).normalize().multiply(speed);

                    entity.setVelocity(v3);

                    // If freeflight is off, check if the entity has reached its
                    // destination, and remove the destination if that happens
                    // to be the case
View Full Code Here

        }
    }

    @EventHandler
    public void entityDamage(EntityDamageEvent event) {
        Entity entity = event.getEntity();
        if (!(entity instanceof Player))
            return;
        final Player player = (Player) entity;
        final ItemStack[] oldArmor = player.getInventory().getArmorContents();
        new BukkitRunnable() {
View Full Code Here

            }
        }

        for (dEntity talker : talkers.filter(dEntity.class)) {

            Entity entity = talker.getBukkitEntity();
            if (entity != null) {
                context.setTalker(entity);
                new DenizenSpeechController(entity).speak(context);
            }
            else {
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.