This commit is contained in:
Felix Cravic 2020-11-27 00:08:32 +01:00
parent fe568abe70
commit 8ae82a81a1
2 changed files with 7 additions and 8 deletions

View File

@ -474,7 +474,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
getVelocity().getY() / tps,
getVelocity().getZ() / tps
);
onGround = CollisionUtils.handlePhysics(this, deltaPos, newPosition, newVelocityOut);
this.onGround = CollisionUtils.handlePhysics(this, deltaPos, newPosition, newVelocityOut);
// Check chunk
if (!ChunkUtils.isLoaded(instance, newPosition.getX(), newPosition.getZ())) {
@ -505,8 +505,8 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
}
}
velocity.copy(newVelocityOut);
velocity.multiply(tps);
this.velocity.copy(newVelocityOut);
this.velocity.multiply(tps);
float drag;
if (onGround) {
@ -528,8 +528,8 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
drag = 0.98f; // air drag
}
velocity.setX(velocity.getX() * drag);
velocity.setZ(velocity.getZ() * drag);
this.velocity.setX(velocity.getX() * drag);
this.velocity.setZ(velocity.getZ() * drag);
sendSynchronization();

View File

@ -2,7 +2,6 @@ package net.minestom.server.entity;
import com.extollit.gaming.ai.path.HydrazinePathFinder;
import com.extollit.gaming.ai.path.model.IPath;
import net.minestom.server.MinecraftServer;
import net.minestom.server.attribute.Attributes;
import net.minestom.server.collision.CollisionUtils;
import net.minestom.server.entity.ai.GoalSelector;
@ -432,7 +431,6 @@ public abstract class EntityCreature extends LivingEntity {
final float radians = (float) Math.atan2(dz, dx);
final float speedX = (float) (Math.cos(radians) * speed);
final float speedY = noGravity ? 0 : -gravityDragPerTick * MinecraftServer.TICK_PER_SECOND;
final float speedZ = (float) (Math.sin(radians) * speed);
lookAlong(dx, direction.getY(), dz);
@ -441,8 +439,9 @@ public abstract class EntityCreature extends LivingEntity {
Vector newVelocityOut = new Vector();
// Prevent ghosting
CollisionUtils.handlePhysics(this, new Vector(speedX, speedY, speedZ), newPosition, newVelocityOut);
this.onGround = CollisionUtils.handlePhysics(this, new Vector(speedX, 0, speedZ), newPosition, newVelocityOut);
// Will move the entity during Entity#tick
getPosition().setX(newPosition.getX());
getPosition().setZ(newPosition.getZ());
}