Add API to retrieve blocks which would be broken by explosion
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Is your feature request related to a problem?
During the implementation of a custom explosion, where I wanted more control over the blocks actually involved in the explosion, I came across a lack of API. Basically, you are currently only able to explode manually using boolean World#createExplosion(...) and its many many overloads. You cannot actually retrieve the blocks that would be broken by a theoretical explosion, and perform your own logic, so not exploding certain blocks, or running some sort of operation on them instead of just removing them.
Describe the solution you'd like.
I'd like a new collection of methods, List<Block> World#getExplodedBlocks(...), which run the underlying ServerExplosion#explode() logic until the this.calculateExplodedPositions() part, and then returns. Perhaps instead of it being a List<Block>, it could be more versatile and instead be a record class, which also contains data for stuff like potential fire locations (if fire is enable) and the damage done to entities. But I am down to discuss the specifics.
Describe alternatives you've considered.
There are basically three alternatives that I could think of, when I encountered this problem:
- Just do a very simple, basic calculation, which just takes all blocks from a radius and calls it a day. No extra logic.
- Run the
World#createExplosionmethod and listen forBlockExplodeEvents (probably the most sane variant atm) - Use NMS + reflection to get access to the
ServerExplosion#calculateExplodedPositions,ServerExplosion#hurtEntities, andServerExplosion#createFiremethods (the one I went with)
Other
None 🚀
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading World#createExplosion(...) and the ServerExplosion#explode() flow, especially calculateExplodedPositions(), hurtEntities(), and createFire(). Compare the proposed API with the existing BlockExplodeEvent alternative. Done would require a settled API design and implementation that exposes the intended explosion results, but the issue leaves those specifics open.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100