-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Particle.onGround is not updated correctly #6595
Comments
This also happens to digging particles. They seem to collide but their velocities are not changed correctly. Possibly this bug is caused by decompiling as vanilla just works fine but the decompiled code acts pretty weird, and forge does not seem to touch Code analysis. The bug is in the // MCP mappings: snapshot-20200322-1.15.1
// Local variables are remapped, old names are commented between [brackets].
public void move(double x, double y, double z) {
if (!this.collidedY) {
double lastX = x; // [d0]
double lastY = y; // [d1]
if (this.canCollide && (x != 0.0D || y != 0.0D || z != 0.0D)) {
Vec3d moveVec = Entity.collideBoundingBoxHeuristically((Entity)null, new Vec3d(x, y, z), this.getBoundingBox(), this.world, ISelectionContext.dummy(), new ReuseableStream<>(Stream.empty())); // [vec3d]
x = moveVec.x;
y = moveVec.y;
z = moveVec.z;
}
if (x != 0.0D || y != 0.0D || z != 0.0D) {
this.setBoundingBox(this.getBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
// 'a < b && a >= b' is equal to 'a == b'
// This condition can be evaluated to: 'Math.abs(y) == (double)1.0E-5F'
// The chance that this evaluates to true is 1 upon 9223372036854775808
// For this to work properly, 'lastY' must more than/equal to approx. zero and 'y' must be less than approx. zero.
if (Math.abs(y) >= (double)1.0E-5F && Math.abs(y) < (double)1.0E-5F) {
this.collidedY = true;
}
// Wait: are we comparing variables to itself?
// vvvvvv This condition is always false, causing onGround to be always false!
this.onGround = y != y && lastY < 0.0D;
if (lastX != x) {
this.motionX = 0.0D;
}
// vvvvvv This condition is also always false!
if (z != z) {
this.motionZ = 0.0D;
}
}
} This method can be patched to solve the problem: public void move(double x, double y, double z) {
if (!this.collidedY) {
double lastX = x; // [d0]
double lastY = y; // [d1]
double lastZ = z; // < Create variable 'lastZ' and assign it to 'z'.
if (this.canCollide && (x != 0.0D || y != 0.0D || z != 0.0D)) {
Vec3d moveVec = Entity.collideBoundingBoxHeuristically((Entity)null, new Vec3d(x, y, z), this.getBoundingBox(), this.world, ISelectionContext.dummy(), new ReuseableStream<>(Stream.empty())); // [vec3d]
x = moveVec.x;
y = moveVec.y;
z = moveVec.z;
}
if (x != 0.0D || y != 0.0D || z != 0.0D) {
this.setBoundingBox(this.getBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
// vvvvv Use 'lastY' instead of 'y'.
if (Math.abs(lastY) >= (double)1.0E-5F && Math.abs(y) < (double)1.0E-5F) {
this.collidedY = true;
}
// vvvvv Use 'lastY' instead of 'y'.
this.onGround = lastY != y && lastY < 0.0D;
if (lastX != x) {
this.motionX = 0.0D;
}
// vvvvv Use 'lastZ' instead of 'z'
if (lastZ != z) {
this.motionZ = 0.0D;
}
}
} |
Minecraft Version: 1.15.2
Forge Version: 31.1.18
Description of issue:
Particle.onGround is not updated correctly, causing particles behave differently between vanilla and forge.
Vanilla:
Forge:
The text was updated successfully, but these errors were encountered: