Optimizing Explosions

Article explaining causes of lag in explosions, and how to reduce it!

This article is for the Explosion feature of WeaponMechanics.

WeaponMechanics uses a custom explosion system; it is completely separate from the Minecraft code (even though it looks very similar!). WeaponMechanics, by default, uses a highly optimized Explosion algorithm. But what if you are still encountering lag?

Falling Blocks

Falling blocks are visual effects added by Block_Damage. Although they are only visual, the math for calculating their collisions can cause a lot of lag. If you have a large explosion, you should either lower the chances for falling blocks, or completely disable them.

<weapon>:
  Explosion:
    Block_Damage:
      Falling_Block_Chance: 5%  # Set this to 0% for best performance

Reducing Rays

Explosions from WeaponMechanics are calculated the same way explosions from vanilla Minecraft are calculated; by casting 16166=153616\cdot 16\cdot 6=1536 rays in all directions. This is expensive on the CPU, especially if you explosion yield is high (>10>10) or you have lots of explosions at the same time (Like an Airstrike).

<weapon>:
  Explosion:
    Explosion_Type_Data:
      Rays: 16  # 16 is the default value. Change to something like 12 for better performance

Changing Explosion Shape

Using Explosion_Shape: DEFAULT will always be taxing on the CPU. If you have a server that has 100s of explosions a minute, you should consider switching to a new shape, like SPHERE.

See Explosion_Shape for more information.

Changing Explosion Exposure

Using Explosion_Exposure: DEFAULT casts a lot of rays for each entity in the radius of the explosion. Switching to the optimized exposure can help reduce the number of rays.

<weapon>:
  Explosion:
    Explosion_Exposure: OPTIMIZED

For a more draconian route, you can use DISTANCE to perform almost NO math per entity (At the cost of drastically reducing the features of an explosion).

Last updated