コード例 #1
0
  @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;
    }
  }
コード例 #2
0
 @Override
 public Vector round() {
   return wrap(m_parent.round());
 }