Exemplo n.º 1
0
 @Override
 public boolean test(Vector vector) {
   if (combined != -1) {
     return FaweCache.getCombined(extent.getLazyBlock(vector)) == combined;
   } else {
     combined = FaweCache.getCombined(extent.getLazyBlock(vector));
     return true;
   }
 }
  @Override
  public boolean apply(Entity entity) throws WorldEditException {
    BaseEntity state = entity.getState();
    if (state != null) {
      Location newLocation;
      Location location = entity.getLocation();

      Vector pivot = from.round().add(0.5, 0.5, 0.5);
      Vector newPosition = transform.apply(location.toVector().subtract(pivot));
      Vector newDirection;

      newDirection =
          transform.isIdentity()
              ? entity.getLocation().getDirection()
              : transform
                  .apply(location.getDirection())
                  .subtract(transform.apply(Vector.ZERO))
                  .normalize();
      newLocation =
          new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);

      // Some entities store their position data in NBT
      state = transformNbtData(state);

      boolean success = destination.createEntity(newLocation, state) != null;

      // Remove
      if (isRemoving() && success) {
        entity.remove();
      }

      return success;
    } else {
      return false;
    }
  }