mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Fix Crossing Domes at Y Level
This commit is contained in:
1 parent
029f460b75
commit
2f4ddb30ec
1 file changed
+11
-5
@@ -351,8 +351,10 @@ public class EntityEnergyDome extends EntityEnergyBarrier {
|
||||
double radialVel = ent.motionX * nx + ent.motionY * ny + ent.motionZ * nz;
|
||||
|
||||
if (wasInside != isInside) {
|
||||
// Entity crossed the boundary this tick — push back to original side
|
||||
double pushDist = wasInside ? (r - 0.3) : (r + 0.3);
|
||||
// Entity crossed the boundary this tick — push back to original side.
|
||||
// Use a larger buffer (1.0) to prevent flying entities from crossing
|
||||
// again in a single tick (their AI hard-sets motionY every tick).
|
||||
double pushDist = wasInside ? (r - 1.0) : (r + 0.3);
|
||||
double surfaceX = posX + nx * pushDist;
|
||||
double surfaceY = posY + ny * pushDist - ent.height * 0.5;
|
||||
double surfaceZ = posZ + nz * pushDist;
|
||||
@@ -366,13 +368,16 @@ public class EntityEnergyDome extends EntityEnergyBarrier {
|
||||
|
||||
teleportEntity(ent, surfaceX, surfaceY, surfaceZ);
|
||||
|
||||
// Cancel radial velocity and add corrective push
|
||||
// Cancel radial velocity and add corrective push (all 3 axes).
|
||||
// The Y component is critical for the dome top where nx/nz ≈ 0:
|
||||
// without it, flying entities get no inward push at the apex.
|
||||
ent.motionX -= radialVel * nx;
|
||||
ent.motionY -= radialVel * ny;
|
||||
ent.motionZ -= radialVel * nz;
|
||||
double pushForce = wasInside ? -0.15 : 0.15;
|
||||
if (canPushInDirection(ent, nx * pushForce, 0, nz * pushForce)) {
|
||||
if (canPushInDirection(ent, nx * pushForce, ny * pushForce, nz * pushForce)) {
|
||||
ent.motionX += nx * pushForce;
|
||||
ent.motionY += ny * pushForce;
|
||||
ent.motionZ += nz * pushForce;
|
||||
}
|
||||
ent.velocityChanged = true;
|
||||
@@ -387,8 +392,9 @@ public class EntityEnergyDome extends EntityEnergyBarrier {
|
||||
ent.motionY -= radialVel * ny;
|
||||
ent.motionZ -= radialVel * nz;
|
||||
double pushForce = isInside ? -0.05 : 0.05;
|
||||
if (canPushInDirection(ent, nx * pushForce, 0, nz * pushForce)) {
|
||||
if (canPushInDirection(ent, nx * pushForce, ny * pushForce, nz * pushForce)) {
|
||||
ent.motionX += nx * pushForce;
|
||||
ent.motionY += ny * pushForce;
|
||||
ent.motionZ += nz * pushForce;
|
||||
}
|
||||
ent.velocityChanged = true;
|
||||
|
||||
Reference in new issue
Block a user