Skip to content

fix: apply TNT protections to Sulfur Cube explosions - #3104

Open
daniel-skopek wants to merge 1 commit into
BentoBoxWorld:developfrom
daniel-skopek:fix/sulfur-cube-explosion-protection
Open

daniel-skopek wants to merge 1 commit into
BentoBoxWorld:developfrom
daniel-skopek:fix/sulfur-cube-explosion-protection

Conversation

@daniel-skopek

Copy link
Copy Markdown
Contributor

Summary

A Sulfur Cube with absorbed TNT explodes as an EntityExplodeEvent whose entity
type is SULFUR_CUBE, not TNT. ExplosionListener only matched primed TNT
and TNT minecarts, so these explosions bypassed TNT_DAMAGE and
WORLD_TNT_DAMAGE. On protected islands that allowed destroying blocks and
damaging entities even when TNT damage was disabled. The AOneBlock magic block
itself was already protected by BlockProtect, but player builds around it were
not.

Changes

  • Resolve SULFUR_CUBE at runtime with findFirstMatchingEnum(...), so the
    listener still loads on servers without the entity.
  • Include SULFUR_CUBE in TNT_TYPES, making Sulfur Cube explosions follow the
    existing TNT_DAMAGE and WORLD_TNT_DAMAGE flags for both blocks and entity
    damage.
  • Gate player ignition of a Sulfur Cube with flint and steel or a fire charge by
    TNT_PRIMING, matching the existing TNT block behaviour.
  • Add regression tests covering allowed and denied Sulfur Cube explosions,
    entity damage, and priming.

Testing

  • ./gradlew test --tests 'world.bentobox.bentobox.listeners.flags.protection.*'
  • ./gradlew test
  • git diff --check

Notes

AOneBlock still ships TNT_DAMAGE: true by default; servers that want Sulfur
Cube explosions blocked there must set it to false. Ignition by redstone,
dispensers or environmental explosions has no player actor, so TNT_PRIMING
does not apply to those paths, but the resulting explosion still respects
TNT_DAMAGE.

A Sulfur Cube exploding with absorbed TNT raises an EntityExplodeEvent
whose entity type is SULFUR_CUBE, not TNT. ExplosionListener only
matched primed TNT and TNT minecarts, so these explosions bypassed
TNT_DAMAGE and WORLD_TNT_DAMAGE and could destroy island blocks.

Resolve SULFUR_CUBE at runtime so older servers still load the listener,
and include it in TNT_TYPES so block and entity damage follow the
existing TNT flags. Also gate player ignition with flint and steel or a
fire charge by TNT_PRIMING.

Adds regression tests for allowed and denied Sulfur Cube explosions,
entity damage and priming.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant