Fix: MaterializeSpell - #1099
Open
DragonsAscent wants to merge 2 commits into
Open
Conversation
DragonsAscent
requested review from
JasperLorelai
and
a lite review from Copilot
and removed request for
Copilot
August 23, 2026 19:01
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed logic bugs that can cause runtime exceptions during non-pattern area placement and can allow cancelled block-place events to still leave blocks placed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes MaterializeSpell so it can place multi-block areas (including patterns) rather than effectively only placing a single block, and refactors placement logic to better handle area parsing, target/support block resolution, and physics/event interactions.
Changes:
- Replaces the single
materialfield with a validateddefaultMaterial, including a safe fallback when config is invalid. - Refactors casting/placement flow into smaller helpers (
parseArea,resolveTargetBlock,materializeArea, etc.) to support area-based placement. - Updates placement logic to support multiple layers/directions and pattern selection (including stretch/randomization behavior).
File summaries
| File | Description |
|---|---|
| core/src/main/java/com/nisovin/magicspells/spells/targeted/MaterializeSpell.java | Refactors and fixes materialization logic to enable correct area/pattern placement and improve block placement validation/handling. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
220
to
222
| for (int z = 0; z < columnSize; z++) { | ||
| //Everytime a shape row is finished, we need to start at the topleft and move down 1 row. | ||
| spawnBlock = patternStart.clone().add(0, y, z); | ||
|
|
||
| //Let's parse the list of patterns for that row. | ||
| if (patterns != null && patternPosition >= patterns.size()) patternPosition = 0; | ||
| if (hasPatterns && patternPosition >= rowPatterns.length) patternPosition = 0; | ||
|
|
Comment on lines
300
to
+307
| if (checkPlugins && player != null) { | ||
| block.setType(material, false); | ||
| block.setBlockData(blockData, false); | ||
| MagicSpellsBlockPlaceEvent event = new MagicSpellsBlockPlaceEvent(block, blockState, against, player.getEquipment().getItemInMainHand(), player, true); | ||
| EventUtil.call(event); | ||
| blockState.update(true); | ||
| if (event.isCancelled()) return false; | ||
|
|
||
| if (falling) blockState.update(true); | ||
| else if (applyPhysics) block.setBlockData(blockData, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Materialize spell now works properly allowing the placement of patterns unlike previous behavior where it only placed a single block.