Skip to content

Fix #3375 and #2811#3415

Open
Vo1dExr wants to merge 4 commits intoAnvil-Dev:dev/1.21/1.6from
Vo1dExr:fix/1.21/1.6
Open

Fix #3375 and #2811#3415
Vo1dExr wants to merge 4 commits intoAnvil-Dev:dev/1.21/1.6from
Vo1dExr:fix/1.21/1.6

Conversation

@Vo1dExr
Copy link
Copy Markdown
Contributor

@Vo1dExr Vo1dExr commented Apr 13, 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 fixes two gameplay bugs related to heatable blocks and anvil hammer interactions, and adjusts frost metal block tag behavior to allow Wither/Ender Dragon destruction.

Changes:

  • Fixes anvil hammer left-click behavior after using items in the offhand by no longer relying on Player#getUsedItemHand().
  • Prevents TNT ignition from normal-tier heatable blocks (e.g., normal tungsten), while still igniting TNT for hotter tiers (and when placing a hot block adjacent to TNT).
  • Removes WITHER_IMMUNE / DRAGON_IMMUNE tags from frost metal-related blocks so they are no longer immune.

Reviewed changes

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

File Description
src/main/java/dev/dubhe/anvilcraft/item/AnvilHammerItem.java Adjusts left-click anvil hammer logic to use main-hand item/slot instead of last-used hand.
src/main/java/dev/dubhe/anvilcraft/init/block/ModBlocks.java Removes Wither/Dragon immunity tags from frost metal blocks; minor formatting adjustments.
src/main/java/dev/dubhe/anvilcraft/block/heatable/HeatableBlock.java Gates TNT ignition logic on heat tier (non-NORMAL), and adds ignition check on placement.

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

Comment on lines +34 to +38
Direction[] directions = Direction.values();
for (Direction direction : directions) {
if (level.getBlockState(pos.relative(direction)).is(Blocks.TNT)
&& HeatRecorder.getTier(level, pos, state).orElse(HeatTier.NORMAL) != HeatTier.NORMAL
) {
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

In onPlace, HeatRecorder.getTier(level, pos, state) is recomputed for every direction even though it only depends on the placed block. Consider computing the tier (or an isHot boolean) once before the loop, and reusing it, to avoid repeated registry scans and improve readability.

Suggested change
Direction[] directions = Direction.values();
for (Direction direction : directions) {
if (level.getBlockState(pos.relative(direction)).is(Blocks.TNT)
&& HeatRecorder.getTier(level, pos, state).orElse(HeatTier.NORMAL) != HeatTier.NORMAL
) {
boolean isHot = HeatRecorder.getTier(level, pos, state).orElse(HeatTier.NORMAL) != HeatTier.NORMAL;
Direction[] directions = Direction.values();
for (Direction direction : directions) {
if (level.getBlockState(pos.relative(direction)).is(Blocks.TNT) && isHot) {

Copilot uses AI. Check for mistakes.
Comment on lines 145 to 158
public static boolean dropAnvil(@Nullable Player player, Level level, BlockPos blockPos) {
if (player == null || level.isClientSide) return false;
ItemStack itemStack = player.getItemInHand(player.getUsedItemHand());
ItemStack itemStack = player.getMainHandItem();
Item item = itemStack.getItem();
if (!(item instanceof AnvilHammerItem anvilHammerItem)) return false;
if (player.getCooldowns().isOnCooldown(anvilHammerItem)) {
return false;
}
if (player.getCooldowns().isOnCooldown(anvilHammerItem)) return false;
player.getCooldowns().addCooldown(itemStack.getItem(), 5);
FallingBlockEntity dummyAnvilEntity = new FallingBlockEntity(EntityType.FALLING_BLOCK, level);
dummyAnvilEntity.blockState = anvilHammerItem.getAnvil().defaultBlockState();
AnvilEvent.OnLand event = new AnvilEvent.OnLand(level, blockPos.above(), dummyAnvilEntity, player.fallDistance);
NeoForge.EVENT_BUS.post(event);
level.playSound(null, blockPos, SoundEvents.ANVIL_LAND, SoundSource.BLOCKS, 1f, 1f);
itemStack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(player.getUsedItemHand()));
itemStack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(InteractionHand.MAIN_HAND));
TriggerUtil.anvilHammerClickBlock(level, blockPos, "left_click");
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

dropAnvil is now hard-coded to the main hand (getMainHandItem() / InteractionHand.MAIN_HAND), but the call site triggers it based on PlayerInteractEvent.LeftClickBlock#getHand(). If the event can ever fire for OFF_HAND (or if this method gets reused elsewhere), this will cancel the event while not operating on the actual hand/item. Consider passing InteractionHand hand into dropAnvil and using player.getItemInHand(hand) + LivingEntity.getSlotForHand(hand) instead of assuming main hand.

Copilot uses AI. Check for mistakes.
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 4 out of 4 changed files in this pull request and generated 2 comments.


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

Comment on lines 147 to 151
if (canStart) {
this.startWaiting(level, pos, stateGetter, generator);
this.updateBlockAndNeighbours(level, pos, stateGetter, generator);
}

this.checkIsDeadlock(level, pos, stateGetter, generator);
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

update() no longer calls updateBlockAndNeighbours() when canStart is false. This breaks cases where the block's redstone output should change without starting a new cycle (e.g., toggling outputInvert via PulseGeneratorBlockEntity#setOutputMode, or syncing POWERED after load/move), because update() is the mechanism those setters/load paths use to refresh the block state. Consider restoring an unconditional updateBlockAndNeighbours(...) at the end of update() (or otherwise ensuring it runs whenever generator.isOutputting() may have changed).

Copilot uses AI. Check for mistakes.
Comment on lines 147 to 151
if (canStart) {
this.startWaiting(level, pos, stateGetter, generator);
this.updateBlockAndNeighbours(level, pos, stateGetter, generator);
}

this.checkIsDeadlock(level, pos, stateGetter, generator);
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This PR is scoped to fixes for #3375 and #2811, but it also changes PulseGenerator behavior (reorders/removes updateBlockAndNeighbours calls). If this is intentional, please mention it in the PR description; otherwise consider reverting or moving these PulseGenerator changes into a separate PR to keep the fix scope focused.

Copilot uses AI. Check for mistakes.
@Vo1dExr Vo1dExr marked this pull request as draft April 16, 2026 17:19
@Vo1dExr Vo1dExr marked this pull request as ready for review April 16, 2026 20:37
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.

[Bug] 常温钨块会点燃TNT [Bug] 脉冲发生器x0循环输出信号错误 [Bug] 副手使用某些物品后铁砧锤左键功能失效

2 participants