Skip to content

Add blacklist to DragonRod and BlockDevourer 为龙杖和方块吞噬器添加黑名单#3379#3380

Merged
QiuShui1012 merged 3 commits intoAnvil-Dev:dev/1.21/1.6from
Chrise2024:dev/1.21/1.6
Mar 30, 2026
Merged

Add blacklist to DragonRod and BlockDevourer 为龙杖和方块吞噬器添加黑名单#3379#3380
QiuShui1012 merged 3 commits intoAnvil-Dev:dev/1.21/1.6from
Chrise2024:dev/1.21/1.6

Conversation

@Chrise2024
Copy link
Copy Markdown
Contributor

@Chrise2024 Chrise2024 commented Mar 30, 2026

  • resolved [Feature] 龙杖挖掘黑名单 #3379
  • 通过#anvilcraft:devour_blacklist.json定义龙杖和方块吞噬器的破坏黑名单
  • 修复龙杖吞噬判定,现在可以对破坏速度为0的方块(如红石粉)正确触发吞噬

Copy link
Copy Markdown

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

Adds a configurable block blacklist for “devour” mechanics, preventing Dragon Rod and Block Devourer from destroying protected blocks via the new #anvilcraft:devour_blacklist block tag (resolves #3379).

Changes:

  • Introduces DEVOUR_BLACKLIST block tag and default entries via datagen.
  • Applies blacklist checks to Dragon Rod devouring and Block Devourer devouring logic.
  • Centralizes “devourable” checks with BlockDevourerBlock.canDevour(...) and reuses it in multiple call sites.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java Skips blacklisted blocks and reuses Block Devourer’s canDevour gate during area devour.
src/main/java/dev/dubhe/anvilcraft/init/block/ModBlockTags.java Adds DEVOUR_BLACKLIST tag key.
src/main/java/dev/dubhe/anvilcraft/event/PlayerEventListener.java Prevents Dragon Rod activation on non-devourable blocks using canDevour.
src/main/java/dev/dubhe/anvilcraft/data/tags/BlockTagLoader.java Adds default entries for DEVOUR_BLACKLIST during tag generation.
src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java Adds canDevour(BlockState) and applies it to block devouring.
src/main/java/dev/dubhe/anvilcraft/anvil/BlockDevourerBehavior.java Uses canDevour to decide whether to move/trigger devouring downward.
src/generated/resources/data/anvilcraft/tags/block/devour_blacklist.json Provides default blacklist contents (trapped + wooden chests).
Comments suppressed due to low confidence (3)

src/main/java/dev/dubhe/anvilcraft/item/DragonRodItem.java:139

  • canDevour is checked before resolving multipart main blocks via getChainableMainPartPos(...). Since that utility can map to a different block type (e.g., piston head -> piston), a block could bypass DEVOUR_BLACKLIST if only the main part is tagged. Re-check canDevour after updating devouringPos/devouringState to the main-part state before destroying.
            if (!BlockDevourerBlock.canDevour(devouringState)) continue;
            if (devouringState.is(ModBlockTags.BLOCK_DEVOURER_PROBABILITY_DROPPING)
                && level.random.nextDouble() > 0.05) {
                level.destroyBlock(devouringPos, false);
                continue;
            }

            devouringPos = MultiPartBlockUtil.getChainableMainPartPos(level, devouringPos);
            devouringState = level.getBlockState(devouringPos);

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

  • canDevour is evaluated before MultiPartBlockUtil.getChainableMainPartPos(...), but that call can change the target to a different block type (e.g., piston head -> piston). With the new DEVOUR_BLACKLIST, this can allow devouring a blacklisted main block as long as the clicked part isn’t tagged. Re-check canDevour after reloading devourBlockState for the resolved main-part position.
        if (!canDevour(devourBlockState)) return;
        if (
            !(anvil instanceof FrostAnvilBlock)
            && devourBlockState.is(ModBlockTags.BLOCK_DEVOURER_PROBABILITY_DROPPING)
            && level.random.nextDouble() > 0.05
        ) {
            level.destroyBlock(devourBlockPos, false);
            return;
        }
        devourBlockPos = MultiPartBlockUtil.getChainableMainPartPos(level, devourBlockPos);
        devourBlockState = level.getBlockState(devourBlockPos);
        if (anvil instanceof FrostAnvilBlock) {

src/main/java/dev/dubhe/anvilcraft/event/PlayerEventListener.java:136

  • handleDragonRod sets the event as canceled when the rod can’t devour the target, but the method continues and will still call DragonRodItem.devourBlock(...) / send the client-hold packet. This can still apply cooldown/durability even though interaction was canceled (e.g., clicking an unbreakable/blacklisted block). After canceling, return early to prevent the devour logic from running.
        if (!DragonRodItem.canDevour(player, stack) || !BlockDevourerBlock.canDevour(state)) event.setCanceled(true);

        if (event.getAction() == PlayerInteractEvent.LeftClickBlock.Action.START && !level.isClientSide) {
            DragonRodItem.devourBlock((ServerLevel) level, player, hand, pos, state, blockFace);
        } else if (event.getAction() == PlayerInteractEvent.LeftClickBlock.Action.CLIENT_HOLD) {
            PacketDistributor.sendToServer(new DragonRodDevourPacket(hand, pos, blockFace));
        }

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

@QiuShui1012 QiuShui1012 merged commit c8e7224 into Anvil-Dev:dev/1.21/1.6 Mar 30, 2026
2 checks passed
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] 龙杖挖掘黑名单

3 participants