/** * Constructs a new bounding box from two opposite corners. * Fails the resulting box would be degenerate (a dimension is 0). * * @param firstCorner The first corner * @param secondCorner The second corner */ public AABB(Vector3i firstCorner, Vector3i secondCorner) { this(checkNotNull(firstCorner, "firstCorner").toDouble(), checkNotNull(secondCorner, "secondCorner").toDouble()); }
/** * Gets the underlying position. * * @return The underlying position */ public Vector3d getPosition() { if (this.position == null) { checkState(this.blockPosition != null); this.position = getBlockPosition().toDouble(); } return this.position; }
/** * Create an entity instance at the given position. * * <p>Creating an entity does not spawn the entity into the world. An entity * created means the entity can be spawned at the given location. If * {@link Optional#empty()} was returned, the entity is not able to spawn at * the given location. Furthermore, this allows for the {@link Entity} to be * customized further prior to traditional "ticking" and processing by core * systems.</p> * * @param type The type * @param position The position * @return An entity, if one was created * @throws IllegalArgumentException If the position or entity type is not * valid to create * @throws IllegalStateException If a constructor cannot be found */ default Entity createEntity(EntityType type, Vector3i position) throws IllegalArgumentException, IllegalStateException { checkNotNull(position, "position"); return createEntity(type, position.toDouble()); }
/** * Create an entity instance at the given position with the default * equipment. * * <p>Creating an entity does not spawn the entity into the world. An entity * created means the entity can be spawned at the given location. If * {@link Optional#empty()} was returned, the entity is not able to spawn at * the given location. Furthermore, this allows for the {@link Entity} to be * customized further prior to traditional "ticking" and processing by core * systems.</p> * * @param type The type * @param position The position * @return An entity, if one was created * @throws IllegalArgumentException If the position or entity type is not * valid to create * @throws IllegalStateException If a constructor cannot be found */ default Entity createEntityNaturally(EntityType type, Vector3i position) throws IllegalArgumentException, IllegalStateException { checkNotNull(position, "position"); return createEntityNaturally(type, position.toDouble()); }
/** * Returns a new transform representing a rotation around an axis, * around a given point. The rotation is given is quarter turns. * The actual rotation is {@code quarterTurns * 90}. The block corner * flag change the point to be the block corner instead of the center. * * @param quarterTurns The number of quarter turns in this rotation * @param axis The axis to rotate around * @param point The point of rotation, as block coordinates * @param blockCorner Whether or not to use the corner of the block * instead of the center * @return The new rotation transform */ public static DiscreteTransform3 fromRotation(int quarterTurns, Axis axis, Vector3i point, boolean blockCorner) { Vector3d pointDouble = point.toDouble(); if (blockCorner) { pointDouble = pointDouble.add(0.5, 0.5, 0.5); } return new DiscreteTransform3(Matrix4d.createTranslation(pointDouble.negate()).rotate(Quaterniond.fromAngleDegAxis(quarterTurns * 90, axis .toVector3d())).translate(pointDouble)); }
/** * Adds a a rotation to this transform, around an axis, * around a given point, and returns it as a new transform. * The rotation is given is quarter turns. The actual rotation * is {@code quarterTurns * 90}. The block corner flag changes * the point to be the block upper corner instead of the center. * * @param quarterTurns The number of quarter turns in this rotation * @param axis The axis to rotate around * @param point The point of rotation, as block coordinates * @param blockCorner Whether or not to use the corner of the block * instead of the center * @return The rotated transform as a copy */ public DiscreteTransform3 withRotation(int quarterTurns, Axis axis, Vector3i point, boolean blockCorner) { Vector3d pointDouble = point.toDouble(); if (blockCorner) { pointDouble = pointDouble.add(0.5, 0.5, 0.5); } return new DiscreteTransform3( this.matrix.translate(pointDouble.negate()).rotate(Quaterniond.fromAngleDegAxis(quarterTurns * 90, axis.toVector3d())) .translate(pointDouble)); }
Vector3d pointDouble = point.toDouble(); if (blockCornerX) { pointDouble = pointDouble.add(0.5, 0, 0);
Vector3d pointDouble = point.toDouble(); if (blockCornerX) { pointDouble = pointDouble.add(0.5, 0, 0);
/** * Constructs a new bounding box from two opposite corners. * Fails the resulting box would be degenerate (a dimension is 0). * * @param firstCorner The first corner * @param secondCorner The second corner */ public AABB(Vector3i firstCorner, Vector3i secondCorner) { this(checkNotNull(firstCorner, "firstCorner").toDouble(), checkNotNull(secondCorner, "secondCorner").toDouble()); }
/** * Get the underlying position. * * @return The underlying position */ public Vector3d getPosition() { if (this.position == null) { checkState(this.blockPosition != null); this.position = getBlockPosition().toDouble(); } return this.position; }
/** * Create an entity instance at the given position. * * <p>Creating an entity does not spawn the entity into the world. An entity * created means the entity can be spawned at the given location. If * {@link Optional#empty()} was returned, the entity is not able to spawn at * the given location. Furthermore, this allows for the {@link Entity} to be * customized further prior to traditional "ticking" and processing by core * systems.</p> * * @param type The type * @param position The position * @return An entity, if one was created * @throws IllegalArgumentException If the position or entity type is not valid to create * @throws IllegalStateException If a constructor cannot be found */ default Entity createEntity(EntityType type, Vector3i position) throws IllegalArgumentException, IllegalStateException { return createEntity(type, position.toDouble()); }
@Override protected final void arrow(final SnipeData v) { this.worldUid = this.world.getUniqueId(); this.origin = this.targetBlock.getBlockPosition().toDouble().add(0.5, 0.5, 0.5); v.sendMessage(TextColors.DARK_PURPLE, "First point selected."); }
/** * Returns a new transform representing a rotation around an axis, * around a given point. The rotation is given is quarter turns. * The actual rotation is {@code quarterTurns * 90}. The block corner * flag change the point to be the block corner instead of the center. * * @param quarterTurns The number of quarter turns in this rotation * @param axis The axis to rotate around * @param point The point of rotation, as block coordinates * @param blockCorner Whether or not to use the corner of the block * instead of the center * @return The new rotation transform */ public static DiscreteTransform3 fromRotation(int quarterTurns, Axis axis, Vector3i point, boolean blockCorner) { Vector3d pointDouble = point.toDouble(); if (blockCorner) { pointDouble = pointDouble.add(0.5, 0.5, 0.5); } return new DiscreteTransform3(Matrix4d.createTranslation(pointDouble.negate()).rotate(Quaterniond.fromAngleDegAxis(quarterTurns * 90, axis .toVector3d())).translate(pointDouble)); }
/** * Adds a a rotation to this transform, around an axis, * around a given point, and returns it as a new transform. * The rotation is given is quarter turns. The actual rotation * is {@code quarterTurns * 90}. The block corner flag changes * the point to be the block upper corner instead of the center. * * @param quarterTurns The number of quarter turns in this rotation * @param axis The axis to rotate around * @param point The point of rotation, as block coordinates * @param blockCorner Whether or not to use the corner of the block * instead of the center * @return The rotated transform as a copy */ public DiscreteTransform3 withRotation(int quarterTurns, Axis axis, Vector3i point, boolean blockCorner) { Vector3d pointDouble = point.toDouble(); if (blockCorner) { pointDouble = pointDouble.add(0.5, 0.5, 0.5); } return new DiscreteTransform3( this.matrix.translate(pointDouble.negate()).rotate(Quaterniond.fromAngleDegAxis(quarterTurns * 90, axis.toVector3d())) .translate(pointDouble)); }
world = player.getWorld(); spawnCoordinates = player.getWorld().getProperties().getSpawnPosition(); player.setLocation(new Location<>(world, spawnCoordinates.toDouble())); } else { if ("-i".equals(args[0])) {
Vector3d pointDouble = point.toDouble(); if (blockCornerX) { pointDouble = pointDouble.add(0.5, 0, 0);
private void addChair(Player player, Location<World> location) { Entity entity = location.getExtent().createEntity(EntityTypes.ARMOR_STAND, location.getBlockPosition().toDouble().sub(-0.5, 1.2, -0.5)); entity.offer(Keys.INVISIBLE, true); entity.offer(Keys.HAS_GRAVITY, false); if (faceCorrectDirection.getValue() && location.supports(Keys.DIRECTION)) { Vector3d euler = LocationUtil.cartesianToEuler(location.get(Keys.DIRECTION).orElse(Direction.NONE).getOpposite().asOffset()); entity.setRotation(euler); player.setRotation(euler); } Sponge.getCauseStackManager().pushCause(player); location.getExtent().spawnEntity(entity); Sponge.getCauseStackManager().popCause(); Chair<?> chair = new Chair<>((ArmorStand) entity, location, player.getLocation()); entity.addPassenger(player); player.sendMessage(Text.of(TextColors.YELLOW, "You sit down!")); chairs.put(player.getUniqueId(), chair); }
Vector3d pointDouble = point.toDouble(); if (blockCornerX) { pointDouble = pointDouble.add(0.5, 0, 0);
private void linePowder(final SnipeData v) { Vector3d target = this.targetBlock.getBlockPosition().toDouble().add(0.5, 0.5, 0.5); Vector3d dir = target.sub(this.origin); double dist = target.distance(this.origin); this.undo = new Undo((int) (dist + 2)); BlockRay<World> ray = BlockRay.from(this.world, this.origin).distanceLimit(dist).direction(dir).build(); perform(v, this.origin.getFloorX(), this.origin.getFloorY(), this.origin.getFloorZ()); while (ray.hasNext()) { Vector3i pos = ray.next().getBlockPosition(); perform(v, pos.getX(), pos.getY(), pos.getZ()); } if (this.continuous) { this.origin = target; } v.owner().storeUndo(this.undo); this.undo = null; }