Add blacklist to DragonRod and BlockDevourer 为龙杖和方块吞噬器添加黑名单#3379#3380
Merged
QiuShui1012 merged 3 commits intoAnvil-Dev:dev/1.21/1.6from Mar 30, 2026
Merged
Add blacklist to DragonRod and BlockDevourer 为龙杖和方块吞噬器添加黑名单#3379#3380QiuShui1012 merged 3 commits intoAnvil-Dev:dev/1.21/1.6from
QiuShui1012 merged 3 commits intoAnvil-Dev:dev/1.21/1.6from
Conversation
QiuShui1012
requested changes
Mar 30, 2026
src/main/java/dev/dubhe/anvilcraft/block/BlockDevourerBlock.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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_BLACKLISTblock 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
canDevouris checked before resolving multipart main blocks viagetChainableMainPartPos(...). Since that utility can map to a different block type (e.g., piston head -> piston), a block could bypassDEVOUR_BLACKLISTif only the main part is tagged. Re-checkcanDevourafter updatingdevouringPos/devouringStateto 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
canDevouris evaluated beforeMultiPartBlockUtil.getChainableMainPartPos(...), but that call can change the target to a different block type (e.g., piston head -> piston). With the newDEVOUR_BLACKLIST, this can allow devouring a blacklisted main block as long as the clicked part isn’t tagged. Re-checkcanDevourafter reloadingdevourBlockStatefor 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
handleDragonRodsets the event as canceled when the rod can’t devour the target, but the method continues and will still callDragonRodItem.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
approved these changes
Mar 30, 2026
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.
#anvilcraft:devour_blacklist.json定义龙杖和方块吞噬器的破坏黑名单