mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Rename with to apply
This commit is contained in:
parent
30464d903d
commit
ca2a2eb233
@ -40,7 +40,7 @@ public class CollisionUtils {
|
|||||||
deltaPosition.z() > 0 ? boundingBox.getBackFace() : boundingBox.getFrontFace());
|
deltaPosition.z() > 0 ? boundingBox.getBackFace() : boundingBox.getFrontFace());
|
||||||
|
|
||||||
return new PhysicsResult(currentPosition.withCoord(zCollision.newPosition),
|
return new PhysicsResult(currentPosition.withCoord(zCollision.newPosition),
|
||||||
deltaPosition.with(((x, y, z) -> new Vec(
|
deltaPosition.apply(((x, y, z) -> new Vec(
|
||||||
xCollision.foundCollision ? 0 : x,
|
xCollision.foundCollision ? 0 : x,
|
||||||
yCollision.foundCollision ? 0 : y,
|
yCollision.foundCollision ? 0 : y,
|
||||||
zCollision.foundCollision ? 0 : z
|
zCollision.foundCollision ? 0 : z
|
||||||
@ -114,7 +114,7 @@ public class CollisionUtils {
|
|||||||
// TODO: block collision boxes
|
// TODO: block collision boxes
|
||||||
// TODO: for the moment, always consider a full block
|
// TODO: for the moment, always consider a full block
|
||||||
if (block.isSolid()) {
|
if (block.isSolid()) {
|
||||||
corners[cornerIndex] = originalCorner.with(((x, y, z) -> new Vec(
|
corners[cornerIndex] = originalCorner.apply(((x, y, z) -> new Vec(
|
||||||
Math.abs(axis.x()) > 10e-16 ? newCorner.blockX() - axis.x() * sign : x,
|
Math.abs(axis.x()) > 10e-16 ? newCorner.blockX() - axis.x() * sign : x,
|
||||||
Math.abs(axis.y()) > 10e-16 ? newCorner.blockY() - axis.y() * sign : y,
|
Math.abs(axis.y()) > 10e-16 ? newCorner.blockY() - axis.y() * sign : y,
|
||||||
Math.abs(axis.z()) > 10e-16 ? newCorner.blockZ() - axis.z() * sign : z
|
Math.abs(axis.z()) > 10e-16 ? newCorner.blockZ() - axis.z() * sign : z
|
||||||
|
@ -547,13 +547,13 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
|||||||
// Convert from blocks/tick to blocks/sec
|
// Convert from blocks/tick to blocks/sec
|
||||||
.mul(tps)
|
.mul(tps)
|
||||||
// Apply drag
|
// Apply drag
|
||||||
.with((x, y, z) -> new Vec(
|
.apply((x, y, z) -> new Vec(
|
||||||
x * drag,
|
x * drag,
|
||||||
!hasNoGravity() ? y * (1 - gravityDragPerTick) : y,
|
!hasNoGravity() ? y * (1 - gravityDragPerTick) : y,
|
||||||
z * drag
|
z * drag
|
||||||
))
|
))
|
||||||
// Prevent infinitely decreasing velocity
|
// Prevent infinitely decreasing velocity
|
||||||
.with(Vec.Operator.EPSILON);
|
.apply(Vec.Operator.EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ package net.minestom.server.utils.block;
|
|||||||
|
|
||||||
import net.minestom.server.entity.LivingEntity;
|
import net.minestom.server.entity.LivingEntity;
|
||||||
import net.minestom.server.instance.block.BlockFace;
|
import net.minestom.server.instance.block.BlockFace;
|
||||||
import net.minestom.server.utils.BlockPosition;
|
|
||||||
import net.minestom.server.utils.Position;
|
|
||||||
import net.minestom.server.utils.Vector;
|
|
||||||
import net.minestom.server.utils.coordinate.Point;
|
import net.minestom.server.utils.coordinate.Point;
|
||||||
import net.minestom.server.utils.coordinate.Pos;
|
import net.minestom.server.utils.coordinate.Pos;
|
||||||
import net.minestom.server.utils.coordinate.Vec;
|
import net.minestom.server.utils.coordinate.Vec;
|
||||||
@ -68,7 +65,7 @@ public class BlockIterator implements Iterator<Point> {
|
|||||||
double secondPosition = 0;
|
double secondPosition = 0;
|
||||||
double thirdPosition = 0;
|
double thirdPosition = 0;
|
||||||
|
|
||||||
Vec startBlock = startClone.with(Vec.Operator.FLOOR);
|
Vec startBlock = startClone.apply(Vec.Operator.FLOOR);
|
||||||
|
|
||||||
if (getXLength(direction) > mainDirection) {
|
if (getXLength(direction) > mainDirection) {
|
||||||
mainFace = getXFace(direction);
|
mainFace = getXFace(direction);
|
||||||
|
@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.DoubleUnaryOperator;
|
import java.util.function.DoubleUnaryOperator;
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an immutable 3D vector.
|
* Represents an immutable 3D vector.
|
||||||
@ -59,7 +58,7 @@ public final class Vec implements Point {
|
|||||||
* @return the created point
|
* @return the created point
|
||||||
*/
|
*/
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
public @NotNull Vec with(@NotNull Operator operator) {
|
public @NotNull Vec apply(@NotNull Operator operator) {
|
||||||
return operator.apply(x, y, z);
|
return operator.apply(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,11 +193,6 @@ public final class Vec implements Point {
|
|||||||
return new Vec(Math.max(x, value), Math.max(y, value), Math.max(z, value));
|
return new Vec(Math.max(x, value), Math.max(y, value), Math.max(z, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(pure = true)
|
|
||||||
public Vec apply(@NotNull UnaryOperator<@NotNull Vec> operator) {
|
|
||||||
return operator.apply(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
public @NotNull Pos asPosition() {
|
public @NotNull Pos asPosition() {
|
||||||
return new Pos(x, y, z);
|
return new Pos(x, y, z);
|
||||||
|
Loading…
Reference in New Issue
Block a user