Skip to content

Conversation

@Argmaster
Copy link
Collaborator

@Argmaster Argmaster commented Apr 16, 2025

Description

This pull request introduces sulfur based explosives:

  • dynamite stick
  • dynamite block

Dynamite stick is crafted from 2 sulfur and 2 coal

image

It can be placed like torch and can be ignited with torch. Explosion is instant and does not harm player.

Dynamite block can be crafted with 16 dynamite sticks

image

It has significantly higher block damage and damage radius

Explosions are done with ray casting and take resistance and health of block they break into account to reduce the radius of the explosion. Blocks marked as air and fluid are not destroyed.

Links

Depends on: #1313
Related to: #849

@Argmaster
Copy link
Collaborator Author

image

image

image

@Argmaster
Copy link
Collaborator Author

image

@IntegratedQuantum
Copy link
Member

I cannot accept this until #610 (to avoid lag spikes) and #81 (to avoid griefing) are resolved.
Alternatively, a gamerule to disable explosives could be a short-term workaround for the survival world until we have those features.

@Argmaster Argmaster mentioned this pull request Apr 17, 2025
@careeoki
Copy link
Contributor

The dynamite block model is clever, but it stops you from making a giant pile of dynamite (without there being a bunch of gaps). I think a standard cube would be fine:
image

@ikabod-kee
Copy link
Collaborator

Question: would a pile of dynamite increase its range, or its power?

New dynamite textures, remove dynamite block model
@Argmaster
Copy link
Collaborator Author

Both, preferably as emergent behavior. I would prefer to avoid dynamite blocks flying around like in minecraft tho. With #1261 we can make dynamite explosion damage blocks it can not break, so consecutive explosions would break blocks damaged by previous ones. As for range, I would like to count how many TNT blocks are touching and merge their explosion strength and range as an optimization.

That said current tag based system (explosionSmall and friends) for explosion control is not acceptable long term. IMO we should allow for arbitrary attributes (that are not performance critical, not for rendering control) for blocks to be stored in hash map of ZonElements. This problem will re-appear every time we add some non-binary configurable trait of a block (or item!),
to name few:

  • food value,
  • explosion strength and radius,
  • fluid spread radius, viscosity
  • inventory capacity for storage blocks
    3-rd party modifications will be interested in this kind of parameters too.

@Argmaster Argmaster self-assigned this Apr 26, 2025
@Argmaster
Copy link
Collaborator Author

Resolved conflicts with network refactor.

@Argmaster Argmaster marked this pull request as ready for review May 1, 2025 11:22
Copy link
Member

@IntegratedQuantum IntegratedQuantum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preliminary review, I haven't looked at the actual explosion logic yet.

@@ -0,0 +1,12 @@
.{
.tags = .{.canBeIgnited, .explosionMedium},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the explosion radius be specifiable as a separate property or something? I'm sure we can spare a u8 per block type for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is wasteful and not a sustainable model. This property will be used by 2 blocks in base game (maybe 5 if you let us be creative). And it is completely irrelevant to performance. Will you add a field for every property that makes sense for 3 blocks? And what if a modification wants to add one of those? Instead we could have a sparse set of hash maps string to zon and just solve that problem in generic way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think it's only a matter of time until addon creators want to make nuclear explosions with this.
Either way this can be done in the future if you want.

@Argmaster
Copy link
Collaborator Author

Damage for stone and mud

image

image

@Argmaster
Copy link
Collaborator Author

Argmaster commented May 18, 2025

Future improvements:

  • Sticks of dynamite should be throwable
  • Sticks of dynamite should be placeable on bottom of a block
  • Delayed explosions with dedicated EntityDataClass
  • Chained explosions
  • Ignition animation
  • Explosion particles
  • Damage to blocks which were not broken but were in explosion radius (Persistent and synced block damage #1261)
  • Entity damage
  • Scale damage with number of dynamite sticks placed in one block
  • Block drops
  • Batched block updates
  • Placeable string / gunpowder to be used as fuse for igniting dynamite from afar
  • Torches replace dynamite when placed on same block and vice versa
  • VTable based item interactions?
  • Maybe we should have system for arbitrary properties? Explosives could use explosionStrength and explosionRadius but adding them for all blocks doesn't make sense.

@Argmaster Argmaster added this to the Long-Term Goals milestone May 24, 2025
defer main.stackAllocator.free(name);
textInput = TextInput.init(.{0, 0}, 128, 22, name, .{.callback = &createWorld}, .{});

const widgetWidth = 160;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call them components, not widgets

if(!main.server.world.?.allowExplosives) return;
doExplode(pos);
}
fn doExplode(pos: Vec3i) void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not believe this belongs in the network code. Maybe the server world would be a more appropiate place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I think they should be block entities and this code should be inside / next to onInteract, tho it is a big change and big redesign. This also would mean we are back to believing whatever client says, unless we introduce server side onInteract.
IMO we should consider it though because it would be an example of block entity with such interaction and some attached metadata (explosion radius).

Copy link
Member

@IntegratedQuantum IntegratedQuantum Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you could just propagate it as a block entity data change, then you can check on the server side, if the gamerule is set.
Implementing it as a state change could also allow adding a short delay and some fuse particles before detonating.

@Argmaster Argmaster marked this pull request as draft June 5, 2025 17:31
@Argmaster
Copy link
Collaborator Author

Closing until it's a priority to integrate similar stuff into engine.

@Argmaster Argmaster closed this Oct 23, 2025
@IntegratedQuantum IntegratedQuantum removed this from the Long-Term Goals milestone Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants