-
Notifications
You must be signed in to change notification settings - Fork 199
Fairly basic. The sequence is something like this:
- Place a TNT block
- Use Flint and Steel on the TNT block
- Create a PrimedTNT entity, spawn it with a fuse of 80 world-ticks.
- On entity tick, countdown the fuse to 0 (it's a byte).
- When 0, despawn the Primed TNT, and do the explosion.
The explosion code is farily straightforward. It calculates a sphere of impact with an explosion factor or 4.0f. It then iterates through all the affected blocks (not Air) and
- Add the coordinates to a list of coordinates affected
- Set the block to Air or break block to take care of potential item drops.
- Randomly (0-3) sets flamable items on Fire.
- If an affected block is another TNT, primes it and sets the fuse to Random(0-80/4)+80/8.
Then it sends an MCPE Explode with the absolute coordinates of the explosion center, a radius of the explosion, and a list of coordinates for all affected blocks.
Depending on your implementation, it will send block updates when you set the blocks above, otherwise you just send them after the explosion. Do note, that sending block updates needs to be handled with care, because it has a tendency of creating a lot of lag on the client as well as the server. MiNET experience minimal lag on a normal TNT, but larger booms (radius of 100 and more) creates a much bigger lag (but still ok).