geforkt von Mirrors/Paper
Make worldborder collisions consistent with Vanilla
Vanilla now requires the use of WorldBorder#isInsideCloseToBorder to consider a border collision
Dieser Commit ist enthalten in:
Ursprung
b66d200b4b
Commit
abff96ed8d
@ -4,27 +4,6 @@ Date: Thu, 27 Oct 2022 15:35:47 +0200
|
||||
Subject: [PATCH] Add config option for spider worldborder climbing
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@javax.annotation.Nullable
|
||||
private UUID originWorld;
|
||||
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
||||
+ public boolean collidingWithWorldBorder; // Paper
|
||||
|
||||
public void setOrigin(@javax.annotation.Nonnull Location location) {
|
||||
this.origin = location.toVector();
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
null, null
|
||||
);
|
||||
|
||||
- if (io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) {
|
||||
+ if (collidingWithWorldBorder = io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) { // Paper - this line *is* correct, ignore the IDE warning about assignments being used as a condition
|
||||
potentialCollisionsVoxel.add(world.getWorldBorder().getCollisionShape());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
@ -34,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
super.tick();
|
||||
if (!this.level().isClientSide) {
|
||||
- this.setClimbing(this.horizontalCollision);
|
||||
+ this.setClimbing(this.horizontalCollision && (this.level().paperConfig().entities.behavior.allowSpiderWorldBorderClimbing || !collidingWithWorldBorder)); // Paper
|
||||
+ this.setClimbing(this.horizontalCollision && (this.level().paperConfig().entities.behavior.allowSpiderWorldBorderClimbing || !io.papermc.paper.util.CollisionUtil.isCollidingWithBorder(this.level().getWorldBorder(), this.getBoundingBox().inflate(io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON)))); // Paper - inflate by +EPSILON as collision will place us outside the border, but just barely
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1649,41 +1649,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return new Vec3(x, y, z);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isAlmostCollidingOnBorder(final WorldBorder worldborder, final AABB boundingBox) {
|
||||
+ return isAlmostCollidingOnBorder(worldborder, boundingBox.minX, boundingBox.maxX, boundingBox.minZ, boundingBox.maxZ);
|
||||
+ public static boolean isCollidingWithBorder(final WorldBorder worldborder, final AABB boundingBox) {
|
||||
+ return isCollidingWithBorder(worldborder, boundingBox.minX, boundingBox.maxX, boundingBox.minZ, boundingBox.maxZ);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isAlmostCollidingOnBorder(final WorldBorder worldborder, final double boxMinX, final double boxMaxX,
|
||||
+ final double boxMinZ, final double boxMaxZ) {
|
||||
+ final double borderMinX = worldborder.getMinX(); // -X
|
||||
+ final double borderMaxX = worldborder.getMaxX(); // +X
|
||||
+
|
||||
+ final double borderMinZ = worldborder.getMinZ(); // -Z
|
||||
+ final double borderMaxZ = worldborder.getMaxZ(); // +Z
|
||||
+
|
||||
+ return
|
||||
+ // Not intersecting if we're smaller
|
||||
+ !voxelShapeIntersect(
|
||||
+ boxMinX + COLLISION_EPSILON, Double.NEGATIVE_INFINITY, boxMinZ + COLLISION_EPSILON,
|
||||
+ boxMaxX - COLLISION_EPSILON, Double.POSITIVE_INFINITY, boxMaxZ - COLLISION_EPSILON,
|
||||
+ borderMinX, Double.NEGATIVE_INFINITY, borderMinZ, borderMaxX, Double.POSITIVE_INFINITY, borderMaxZ
|
||||
+ )
|
||||
+ &&
|
||||
+
|
||||
+ // Are intersecting if we're larger
|
||||
+ voxelShapeIntersect(
|
||||
+ boxMinX - COLLISION_EPSILON, Double.NEGATIVE_INFINITY, boxMinZ - COLLISION_EPSILON,
|
||||
+ boxMaxX + COLLISION_EPSILON, Double.POSITIVE_INFINITY, boxMaxZ + COLLISION_EPSILON,
|
||||
+ borderMinX, Double.NEGATIVE_INFINITY, borderMinZ, borderMaxX, Double.POSITIVE_INFINITY, borderMaxZ
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isCollidingWithBorderEdge(final WorldBorder worldborder, final AABB boundingBox) {
|
||||
+ return isCollidingWithBorderEdge(worldborder, boundingBox.minX, boundingBox.maxX, boundingBox.minZ, boundingBox.maxZ);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isCollidingWithBorderEdge(final WorldBorder worldborder, final double boxMinX, final double boxMaxX,
|
||||
+ final double boxMinZ, final double boxMaxZ) {
|
||||
+ public static boolean isCollidingWithBorder(final WorldBorder worldborder, final double boxMinX, final double boxMaxX,
|
||||
+ final double boxMinZ, final double boxMaxZ) {
|
||||
+ final double borderMinX = worldborder.getMinX(); // -X
|
||||
+ final double borderMaxX = worldborder.getMaxX(); // +X
|
||||
+
|
||||
@ -1716,11 +1687,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ boolean ret = false;
|
||||
+
|
||||
+ if ((collisionFlags & COLLISION_FLAG_CHECK_BORDER) != 0) {
|
||||
+ if (CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), aabb)) {
|
||||
+ final WorldBorder worldBorder = world.getWorldBorder();
|
||||
+ if (CollisionUtil.isCollidingWithBorder(worldBorder, aabb) && entity != null && worldBorder.isInsideCloseToBorder(entity, aabb)) {
|
||||
+ if (checkOnly) {
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ final VoxelShape borderShape = world.getWorldBorder().getCollisionShape();
|
||||
+ final VoxelShape borderShape = worldBorder.getCollisionShape();
|
||||
+ intoVoxel.add(borderShape);
|
||||
+ ret = true;
|
||||
+ }
|
||||
@ -2346,31 +2318,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ io.papermc.paper.util.CollisionUtil.getCollisions(
|
||||
+ world, this, collisionBox, potentialCollisionsVoxel, potentialCollisionsBB,
|
||||
+ (0),
|
||||
+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER,
|
||||
+ null, null
|
||||
+ );
|
||||
+
|
||||
+ if (io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) {
|
||||
+ potentialCollisionsVoxel.add(world.getWorldBorder().getCollisionShape());
|
||||
+ if (potentialCollisionsVoxel.isEmpty() && potentialCollisionsBB.isEmpty()) {
|
||||
+ return movement;
|
||||
+ }
|
||||
|
||||
- if (this.maxUpStep() > 0.0F && flag3 && (flag || flag2)) {
|
||||
- Vec3 vec3d2 = Entity.collideBoundingBox(this, new Vec3(movement.x, (double) this.maxUpStep(), movement.z), axisalignedbb, this.level(), list);
|
||||
- Vec3 vec3d3 = Entity.collideBoundingBox(this, new Vec3(0.0D, (double) this.maxUpStep(), 0.0D), axisalignedbb.expandTowards(movement.x, 0.0D, movement.z), this.level(), list);
|
||||
+ if (potentialCollisionsVoxel.isEmpty() && potentialCollisionsBB.isEmpty()) {
|
||||
+ return movement;
|
||||
+ }
|
||||
+
|
||||
+ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
|
||||
+
|
||||
|
||||
- if (vec3d3.y < (double) this.maxUpStep()) {
|
||||
- Vec3 vec3d4 = Entity.collideBoundingBox(this, new Vec3(movement.x, 0.0D, movement.z), axisalignedbb.move(vec3d3), this.level(), list).add(vec3d3);
|
||||
+ if (stepHeight > 0.0
|
||||
+ && (onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0))
|
||||
+ && (limitedMoveVector.x != movement.x || limitedMoveVector.z != movement.z)) {
|
||||
+ Vec3 vec3d2 = io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(movement.x, stepHeight, movement.z), currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
|
||||
+ final Vec3 vec3d3 = io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(0.0, stepHeight, 0.0), currBoundingBox.expandTowards(movement.x, 0.0, movement.z), potentialCollisionsVoxel, potentialCollisionsBB);
|
||||
|
||||
- if (vec3d3.y < (double) this.maxUpStep()) {
|
||||
- Vec3 vec3d4 = Entity.collideBoundingBox(this, new Vec3(movement.x, 0.0D, movement.z), axisalignedbb.move(vec3d3), this.level(), list).add(vec3d3);
|
||||
+
|
||||
+ if (vec3d3.y < stepHeight) {
|
||||
+ final Vec3 vec3d4 = io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(movement.x, 0.0D, movement.z), currBoundingBox.move(vec3d3), potentialCollisionsVoxel, potentialCollisionsBB).add(vec3d3);
|
||||
|
||||
|
@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@javax.annotation.Nullable
|
||||
private UUID originWorld;
|
||||
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
|
||||
public boolean collidingWithWorldBorder; // Paper
|
||||
+ public boolean fixedPose = false; // Paper
|
||||
|
||||
public void setOrigin(@javax.annotation.Nonnull Location location) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren