Skip to content

Fix/sword blocking mechanic#1533

Open
ModMaker101 wants to merge 4 commits intoMCLCE:mainfrom
ModMaker101:fix/sword-blocking-mechanic
Open

Fix/sword blocking mechanic#1533
ModMaker101 wants to merge 4 commits intoMCLCE:mainfrom
ModMaker101:fix/sword-blocking-mechanic

Conversation

@ModMaker101
Copy link
Copy Markdown
Contributor

Description

Implements sword blocking mechanics and interaction locks to align with Java 1.8 behavior and resolves some errors.

Changes

Previous Behavior

Players could still mine or attack while in the blocking state. Damage reduction was just a mess dmg = (1 + dmg) * 0.5, and swing animations would persist.

Root Cause

Missing state checks for isBlocking() in input handling methods. The damage formula was just, no.

New Behavior

Blocking now correctly overrides attacking and mining. Damage is reduced by exactly 50%. The block animation correctly cancels active swings and resets block breaking progress.

Fix Implementation

  • Added isBlocking() checks to input handlers to return early.
  • Added logic to reset isDestroying and progress if a player starts blocking.
  • Adjusted actuallyHurt formula to dmg * 0.5 and updated startUsingItem to reset swing timers when a block animation begins.

AI Use Disclosure

None.

Related Issues

Sources

Sword Blocking Wiki
Java 1.8 Wiki

2026-04-19.21-36-15.mp4

It looks like I'm just blocking, but I'm actually holding/clicking left mouse button.

2026-04-19.23-22-08.mp4

From my own testing, I testes right clicking with a sword which blocks and reduces damaged by 50%, attacking then immediately blocking in which after the attack the block commences overriding the attack animation, tried attacking while blocking in which the attack did not go through, tried mining while blocking and didn't go through, try to mine while blocking in which it did not go through, tried blocking and mining while rapidly switching and it did not break. Sorry for this I was not feeling like making this look good.

ModMaker101 and others added 4 commits April 16, 2026 16:07
- Fixed MCLCE#1532 by makingthe blocking correctly reduces damage; per Java 1.8 mechs.
- Fixed an attack going through while blocking.
- Fixed a bug where you could mine while blocking.
- Swing animation while blocking was overrided; per Java 1.8 mechs.
@IsraelDXPP
Copy link
Copy Markdown

works very good

@DrPerkyLegit
Copy link
Copy Markdown
Contributor

attacking while being able to block was a key aspect of blocking, existed in java till they removed it if i remember right

@ModMaker101
Copy link
Copy Markdown
Contributor Author

Oh yeah, you're right I added it alongside the animation canceling. I'll fix it right now.

@ModMaker101
Copy link
Copy Markdown
Contributor Author

Wait no, my PR is correct. You aren't allowed to attack while blocking that was a bug. Try playing 1.8.9 you can't attack while blocking. Now if you're talking about block-hitting than my thing has that implemented.

@ModMaker101
Copy link
Copy Markdown
Contributor Author

And since 1.8.9 is considered the gold standard for PVP before 1.9 I think I'll stick with what I have for now. But 1.6 vs. 1.8 in terms of PVP there are a few differences between smoothness which this PR does NOT address.

@DrPerkyLegit
Copy link
Copy Markdown
Contributor

DrPerkyLegit commented Apr 22, 2026 via email

@ModMaker101
Copy link
Copy Markdown
Contributor Author

It brings some aspects of 1.8.9 to 1.6.4 I'm addressing 1 of the biggest issues. And after trying 1.6.4, NO, you cannot hit while blocking. So, I'm not addressing the biggest part of 1.8.9 to this, but I'm fixing a bug.

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]

3 participants