WeaponMechanics
All WikisDownloadDonate
  • Home
  • Weapon Modules
    • Info
    • Shoot
      • Spread
      • Recoil
    • Scope
    • Reload
      • Ammo
    • Skin
    • Projectile
      • Sticky
      • Bouncy
      • Through
    • Explosion
      • Block Damage
    • Damage
      • Damage Modifiers
    • Firearm_Action
    • Melee
  • Trigger
  • Addons
  • Common Questions
  • Developer API
    • Cloning Repository
    • Projectile Scripts
  • šŸ“„Articles
    • Optimizing Explosions
Powered by GitBook
On this page
  • Falling Blocks
  • Reducing Rays
  • Changing Explosion Shape
  • Changing Explosion Exposure
  1. Articles

Optimizing Explosions

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

Last updated 1 year ago

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 . 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 16ā‹…16ā‹…6=153616\cdot 16\cdot 6=153616ā‹…16ā‹…6=1536 rays in all directions. This is expensive on the CPU, especially if you explosion yield is high (>10>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

This trick only works for Explosion_Shape: DEFAULT, other explosion shapes will not work.

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.

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).

See for more information.

šŸ“„
Block_Damage
Explosion_Shape