Debugify

Debugify

16M Downloads

[Bug] Fix for MC-46766 introduces more bugs

pau101 opened this issue ยท 0 comments

commented

Bug Description

The included fix for MC-46766 does not actually cancel an ongoing block destroy if game mode is suddenly updated to spectator. When leaving spectator the destruction will continue where it left off. This is due to the patch simply canceling the method outright with no attempt to MultiPlayerGameMode#stopDestroyBlock.

@Inject(method = "continueAttack", at = @At("HEAD"), cancellable = true)
private void onHandleBlockBreaking(boolean bl, CallbackInfo ci) {
if (gameMode.getPlayerMode() == GameType.SPECTATOR)
ci.cancel();
}

In addition, while in spectator and having opened any screen such as the inventory the player is no longer able to punch a mob to begin spectating it. This is due to Minecraft#missTime being nonzero preventing an attack from occurring which is set to 10000 when a screen is open. The miss time value is decremented in Minecraft#tick and is only reset to zero in Minecraft#continueAttack when the attack key is not being held/otherwise disabled.

How to Reproduce?

Block destruction:

  1. Set up two command blocks, first one setting player to spectator, and second to survival with a delay in between triggered by a pressure plate
  2. Start mining a block
  3. Walk on pressure plate
  4. Wait
  5. Notice breaking continues without needing to start mining again

Mob spectate:

  1. Spawn a pig
  2. Enter spectator
  3. Open and close inventory
  4. Punch pig
  5. Notice nothing

Expected Behavior

The fix for MC-46766 should stop block destruction in spectator mode while not breaking attack functionality.

Proposed solution:
Rewrite the mixin to use @ModifyArg inside Minecraft#handleKeybinds to pass false into Minecraft#continueAttack when spectator.

Version

1.19.4+1.0

Fabric/Quilt Loader Version

0.11.2 for 1.19.4

Logs or additional context

No response

Has not been reported.

  • I made sure this bug hasn't already been reported.

Is on most update to date version.

  • I made sure I am using the most up to date fabric/quilt loader and mod version.