Code Patterns

Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.

← Back to Patterns
entity

Stop Velocity on Collision

Stop entity movement instantly when collision is detected using ApplyForce interaction. Use Force: 0.01 with ChangeVelocityType: Set to zero out velocity.

Example Code

java
{
  "Type": "ApplyForce",
  "$Comment": "Instantly stops player velocity by setting it to 0",
  "Force": 0.01,
  "Direction": {
    "X": 0,
    "Y": 0,
    "Z": 1
  },
  "ChangeVelocityType": "Set",
  "RunTime": 0.1,
  "WaitForGround": false,
  "VelocityConfig": {
    "AirResistance": 0.97,
    "GroundResistance": 0.95,
    "Threshold": 1.0,
    "Style": "Linear"
  }
}

Common Mistakes

- Direction must have at least one non-zero value (e.g., Z: 1), otherwise player gets stuck - VelocityConfig is REQUIRED, game crashes without it - Force: 0 exact may cause issues, use 0.01 instead - Without RunTime, the effect stays active and blocks normal movement