Skip to content

Fix: MaterializeSpell - #1099

Open
DragonsAscent wants to merge 2 commits into
TheComputerGeek2:mainfrom
DragonsAscent:materialize-fix
Open

Fix: MaterializeSpell#1099
DragonsAscent wants to merge 2 commits into
TheComputerGeek2:mainfrom
DragonsAscent:materialize-fix

Conversation

@DragonsAscent

Copy link
Copy Markdown
Collaborator

Materialize spell now works properly allowing the placement of patterns unlike previous behavior where it only placed a single block.

@DragonsAscent
DragonsAscent requested review from JasperLorelai and a lite review from Copilot and removed request for Copilot August 23, 2026 19:01
Copilot AI lite review requested due to automatic review settings August 23, 2026 21:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 material field with a validated defaultMaterial, 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);
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.

2 participants