Remove unnecessary casts

This commit is contained in:
themode 2021-01-25 19:33:53 +01:00
parent 3067f1daaa
commit 5f75ea7d3a
3 changed files with 18 additions and 17 deletions

View File

@ -115,9 +115,9 @@ public class CollisionUtils {
} }
// find the corner which moved the least // find the corner which moved the least
float smallestDisplacement = Float.POSITIVE_INFINITY; double smallestDisplacement = Double.POSITIVE_INFINITY;
for (int i = 0; i < corners.length; i++) { for (int i = 0; i < corners.length; i++) {
final float displacement = (float) corners[i].distance(cornersCopy[i]); final double displacement = corners[i].distance(cornersCopy[i]);
if (displacement < smallestDisplacement) { if (displacement < smallestDisplacement) {
smallestDisplacement = displacement; smallestDisplacement = displacement;
} }

View File

@ -93,9 +93,9 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
// Velocity // Velocity
protected Vector velocity = new Vector(); // Movement in block per second protected Vector velocity = new Vector(); // Movement in block per second
protected float gravityDragPerTick; protected double gravityDragPerTick;
protected float gravityAcceleration; protected double gravityAcceleration;
protected float gravityTerminalVelocity; protected double gravityTerminalVelocity;
protected int gravityTickCount; // Number of tick where gravity tick was applied protected int gravityTickCount; // Number of tick where gravity tick was applied
private boolean autoViewable; private boolean autoViewable;
@ -485,8 +485,8 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
Vector newVelocityOut = new Vector(); Vector newVelocityOut = new Vector();
// Gravity force // Gravity force
final float gravityY = !noGravity ? Math.min( final double gravityY = !noGravity ? Math.min(
gravityDragPerTick + (gravityAcceleration * (float) gravityTickCount), gravityDragPerTick + (gravityAcceleration * (double) gravityTickCount),
gravityTerminalVelocity) : 0f; gravityTerminalVelocity) : 0f;
final Vector deltaPos = new Vector( final Vector deltaPos = new Vector(
@ -711,7 +711,8 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
* Changes the internal entity bounding box. * Changes the internal entity bounding box.
* <p> * <p>
* WARNING: this does not change the entity hit-box which is client-side. * WARNING: this does not change the entity hit-box which is client-side.
* @param x the bounding box X size *
* @param x the bounding box X size
* @param y the bounding box Y size * @param y the bounding box Y size
* @param z the bounding box Z size * @param z the bounding box Z size
*/ */
@ -814,7 +815,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
* *
* @return the gravity drag per tick in block * @return the gravity drag per tick in block
*/ */
public float getGravityDragPerTick() { public double getGravityDragPerTick() {
return gravityDragPerTick; return gravityDragPerTick;
} }
@ -823,7 +824,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
* *
* @return the gravity acceleration in block * @return the gravity acceleration in block
*/ */
public float getGravityAcceleration() { public double getGravityAcceleration() {
return gravityAcceleration; return gravityAcceleration;
} }
@ -832,7 +833,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
* *
* @return the maximum gravity velocity in block * @return the maximum gravity velocity in block
*/ */
public float getGravityTerminalVelocity() { public double getGravityTerminalVelocity() {
return gravityTerminalVelocity; return gravityTerminalVelocity;
} }

View File

@ -422,15 +422,15 @@ public class Vector implements PublicCloneable<Vector> {
double sinTheta = Math.sin(angle); double sinTheta = Math.sin(angle);
double dotProduct = this.dot(axis); double dotProduct = this.dot(axis);
this.x = (float) (x2 * dotProduct * (1d - cosTheta) this.x = x2 * dotProduct * (1d - cosTheta)
+ x * cosTheta + x * cosTheta
+ (-z2 * y + y2 * z) * sinTheta); + (-z2 * y + y2 * z) * sinTheta;
this.y = (float) (y2 * dotProduct * (1d - cosTheta) this.y = y2 * dotProduct * (1d - cosTheta)
+ y * cosTheta + y * cosTheta
+ (z2 * x - x2 * z) * sinTheta); + (z2 * x - x2 * z) * sinTheta;
this.z = (float) (z2 * dotProduct * (1d - cosTheta) this.z = z2 * dotProduct * (1d - cosTheta)
+ z * cosTheta + z * cosTheta
+ (-y2 * x + x2 * y) * sinTheta); + (-y2 * x + x2 * y) * sinTheta;
return this; return this;
} }