There are two types of collisions events: BLOCK_COLLISION and ELEMENT_COLLISION You can register callbacks for them like so:
// Element V Terrain
ElementCollisionEvents.BLOCK_COLLISION.register((element, terrain, impulse) -> {
if (element instanceof MyCustomPhysicsEntity) {
if (terrain.getBlockState().getBlock().equals(Blocks.BRICKS)) {
System.out.println("Collided with bricks!!");
}
}
});
// Element V Element
ElementCollisionEvents.ELEMENT_COLLISION.register((element1, element2, impulse) -> {
if (element1 instanceof MyCustomPhysicsEntity && element2 instanceof MyCustomPhysicsEntity) {
System.out.println("Element collision!!");
}
});
Physics Space Events
There are four available physics space events: INIT, STEP, ELEMENT_ADDED, and ELEMENT_REMOVED. You can register callbacks for them like so: