Record Class Viscosity

java.lang.Object
java.lang.Record
fr.robie.machineengine.api.resource.fluid.Viscosity
Record Components:
speed - walking and swimming speed multiplier (movement_speed), above 0
gravity - gravity multiplier (1.20.5+), 0 or more
jump - jump strength multiplier (1.20.5+), 0 or more
swim - added water_movement_efficiency (1.21+), 0 to 1: above 0 swims faster than water
damping - player velocity lost every 2 ticks inside, 0 to 0.9 (thick fluids)
entityDrag - velocity other entities lose every 2 ticks inside, 0 to 0.9

public record Viscosity(double speed, double gravity, double jump, double swim, double damping, double entityDrag) extends Record
How a fluid moves things inside it, compared with water (all factors 1 and no damping = water).

Players are moved by their client, so their speed, gravity and jump are attribute modifiers the client predicts (smooth). Water's swimming acceleration can only be raised that way (swim), never lowered: fluids thicker than water use damping, which the server applies to the player's velocity (it can stutter a little). Other entities (mobs, items, boats) are moved by the server, so entityDrag is smooth for them.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Viscosity
    Water: changes nothing.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Viscosity(double speed, double gravity, double jump, double swim, double damping, double entityDrag)
    Creates an instance of a Viscosity record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the damping record component.
    double
    Returns the value of the entityDrag record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    double
    Returns the value of the gravity record component.
    final int
    Returns a hash code value for this object.
    boolean
    Whether this changes nothing compared with water.
    double
    Returns the value of the jump record component.
    double
    Returns the value of the speed record component.
    double
    Returns the value of the swim record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • WATER

      public static final Viscosity WATER
      Water: changes nothing.
  • Constructor Details

    • Viscosity

      public Viscosity(double speed, double gravity, double jump, double swim, double damping, double entityDrag)
      Creates an instance of a Viscosity record class.
      Parameters:
      speed - the value for the speed record component
      gravity - the value for the gravity record component
      jump - the value for the jump record component
      swim - the value for the swim record component
      damping - the value for the damping record component
      entityDrag - the value for the entityDrag record component
  • Method Details

    • isWater

      public boolean isWater()
      Whether this changes nothing compared with water.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • speed

      public double speed()
      Returns the value of the speed record component.
      Returns:
      the value of the speed record component
    • gravity

      public double gravity()
      Returns the value of the gravity record component.
      Returns:
      the value of the gravity record component
    • jump

      public double jump()
      Returns the value of the jump record component.
      Returns:
      the value of the jump record component
    • swim

      public double swim()
      Returns the value of the swim record component.
      Returns:
      the value of the swim record component
    • damping

      public double damping()
      Returns the value of the damping record component.
      Returns:
      the value of the damping record component
    • entityDrag

      public double entityDrag()
      Returns the value of the entityDrag record component.
      Returns:
      the value of the entityDrag record component