Code Patterns
Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.
All
225
Command
60
Damage
2
Ecs
27
Entity
5
Gui
75
Interaction
2
Inventory
4
Moderation
3
Permission
2
Player
9
Plugin
4
Storage
2
Teleport
3
Ui
22
Util
5
← Back to Patterns
java
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
{
"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