Esempio n. 1
0
  public static void replaceMinecarts(EntityMinecart toreplace, EntityMinecart with) {
    with.yaw = toreplace.yaw;
    with.pitch = toreplace.pitch;
    with.lastX = toreplace.lastX;
    with.lastY = toreplace.lastY;
    with.lastZ = toreplace.lastZ;
    with.locX = toreplace.locX;
    with.locY = toreplace.locY;
    with.locZ = toreplace.locZ;
    with.motX = toreplace.motX;
    with.motY = toreplace.motY;
    with.motZ = toreplace.motZ;
    with.b = toreplace.b;
    with.c = toreplace.c;
    with.fallDistance = toreplace.fallDistance;
    with.ticksLived = toreplace.ticksLived;
    with.uniqueId = toreplace.uniqueId;
    with.setDamage(toreplace.getDamage());
    ItemUtil.transfer(toreplace, with);
    with.setDerailedVelocityMod(toreplace.getDerailedVelocityMod());
    with.setFlyingVelocityMod(toreplace.getFlyingVelocityMod());
    // force removal in chunk
    with.dead = false;
    toreplace.dead = true;
    toreplace.ag = true;
    // Set the chunk coordinates
    if (toreplace.ah == 0 && toreplace.ai == 0 && toreplace.aj == 0) {
      // System.out.println("FUUU!");
    }
    with.ah = toreplace.ah;
    with.ai = toreplace.ai;
    with.aj = toreplace.aj;

    // preserve the Bukkit entity, simply swap the contents
    CraftMinecart bukkitEntity = bukkitEntityField.get(toreplace);
    if (bukkitEntity != null) {
      bukkitEntity.setHandle(with);
      bukkitEntityField.set(with, bukkitEntity);
    }

    // swap
    MinecartSwapEvent.call(toreplace, with);
    WorldUtil.getTracker(toreplace.world).untrackEntity(toreplace);
    toreplace.world.removeEntity(toreplace);
    with.world.addEntity(with);
    if (toreplace.passenger != null) toreplace.passenger.setPassengerOf(with);
  }
Esempio n. 2
0
 /**
  * Gets the tracker entry of the entity specified
  *
  * @param entity to get it for
  * @return entity tracker entry, or null if none is set
  */
 public static EntityTrackerEntry getTrackerEntry(Entity entity) {
   return (EntityTrackerEntry) WorldUtil.getTracker(entity.world).trackedEntities.get(entity.id);
 }