Skip to content

Add DragonRod and Devourer's devour priority judgement 吞噬额外判断#3383

Open
Chrise2024 wants to merge 11 commits intoAnvil-Dev:dev/1.21/1.6from
Chrise2024:misc
Open

Add DragonRod and Devourer's devour priority judgement 吞噬额外判断#3383
Chrise2024 wants to merge 11 commits intoAnvil-Dev:dev/1.21/1.6from
Chrise2024:misc

Conversation

@Chrise2024
Copy link
Copy Markdown
Contributor

@Chrise2024 Chrise2024 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #3382 by adding an attachment-aware “devour ordering” so blocks that would otherwise pop off (torches, redstone dust, etc.) can be handled before their supporting blocks are removed.

Changes:

  • Added DevouringLevelReader (a wrapper LevelReader) to simulate “to-be-devoured blocks are already air” when evaluating BlockState#canSurvive.
  • Updated DragonRodItem devour logic to split blocks into “primary” vs “secondary” destruction passes using survivability checks.
  • Updated BlockDevourerBlock devour logic to use survivability checks (plus chain-devour handling) to influence devour order.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java New fake LevelReader used to evaluate survivability as if devoured blocks were already removed.
src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java Uses the fake reader to reorder destruction and reduce attachment pop-off drops.
src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java Applies survivability-based ordering to block devourer (including chain devouring).
Comments suppressed due to low confidence (1)

src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java:33

  • import net.minecraft.world.level.block.Blocks; appears unused in this file (no Blocks. references). If your build enables unused-import checks, this will fail compilation; please remove the import.
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DirectionalBlock;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.RenderShape;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java
Comment thread src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java Outdated
Comment on lines 254 to 270
if (level.getBlockState(devourBlockPos).canSurvive(devouringLevelReader, devourBlockPos)) {
devourSingleBlockInternalLogic(level, anvil, devourBlockPos, filteredBlockPosList, itemHandlerList, center);
} else {
secondaryBlockPosList.add(devourBlockPos);
}
}
DevouringLevelReader chainDevouringLevelReader = new DevouringLevelReader(level, chainDevourBlockPosList);
for (BlockPos devourBlockPos : chainDevourBlockPosList) {
if (level.getBlockState(devourBlockPos).canSurvive(chainDevouringLevelReader, devourBlockPos)) {
devourSingleBlockInternalLogic(level, anvil, devourBlockPos, filteredBlockPosList, itemHandlerList, center);
} else {
secondaryBlockPosList.add(devourBlockPos);
}
}
for (BlockPos devourBlockPos : secondaryBlockPosList) {
devourSingleBlockInternalLogic(level, anvil, devourBlockPos, filteredBlockPosList, itemHandlerList, center);
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The survivability-based ordering appears inverted. Blocks that cannot survive when other devoured blocks are treated as air are the ones that need to be devoured first (to avoid attachment blocks popping/dropping after their support is removed). Here, canSurvive(...) blocks are processed first and non-survivors are deferred to secondaryBlockPosList, which likely recreates the original drop problem. Swap the branches so non-survivors are devoured before survivors (apply similarly to the chain loop).

Copilot uses AI. Check for mistakes.
Comment thread src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevourUtil.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevourUtil.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevourUtil.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevouringLevelReader.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevourUtil.java Outdated
Comment thread src/main/java/dev/dubhe/anvilcraft/util/DevourUtil.java
@@ -207,7 +202,7 @@ public static int calculateDamage(ItemStack dragonRod) {
case 9 -> 4;
default -> 0;
};
Comment thread src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +80 to +88

for (BlockPos devourBlockPos : devourTargets) {
BlockState devourState = level.getBlockState(devourBlockPos);
if (!DevourUtil.shouldDevour(devourState)) continue;
BlockPos normalizedBlockPos = MultiPartBlockUtil.getChainableMainPartPos(level, devourBlockPos);
if (normalizedBlockPos.equals(devourBlockPos)) {
devourBlockPos = normalizedBlockPos;
devourState = level.getBlockState(normalizedBlockPos);
}
Comment on lines +64 to +76
Set<BlockPos> devourTargets = Streams
.stream(BlockPos.betweenClosed(a, b))
.flatMap(bottomPos -> {
// dh = 0 when DOWN, UP; above dh is chain range
int dh = devourDirection.getStepY() != 0 ? 0 : 2 * range;
int cy = bottomPos.getY() + dh;
return Streams
.stream(BlockPos.betweenClosed(bottomPos, bottomPos.atY(cy + chainCount)))
.map(BlockPos::immutable)
.takeWhile(pos -> pos.getY() <= cy || DevourUtil.shouldChainDevour(level.getBlockState(pos)));
// in common devour OR chain until unchainable
})
.collect(Collectors.toSet());
return;
}
boolean shouldDrop = !devouringState.is(ModBlockTags.BLOCK_DEVOURER_PROBABILITY_DROPPING)
|| level.random.nextDouble() <= 0.05;
default -> 0;
};
return Math.min(damage, Math.max(dragonRod.getMaxDamage() - dragonRod.getDamageValue(), 1));
return Mth.clamp(dragonRod.getMaxDamage() - dragonRod.getDamageValue(), 1, damage);
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.

[Feature] 龙杖破坏额外判定

2 participants