Skip to content

Commit

Permalink
fix: fix missing block breaking particle when breaking block.
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jan 23, 2025
1 parent e4cb2c0 commit 444fe29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Unless otherwise specified, any version comparison below is the comparison of se
- Explosion now calculates entity exposure correctly. In previous version any non-air block will block the explosion ray.
- Explosion damage now scales with game difficulty.
- Fixed a rare NPE exception that may occur if player disconnect when joining the server.
- Fixed missing block breaking particle when breaking block.

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,24 @@ protected void sendBreakingPracticeAndTime(EntityPlayer player, long currentTime
updateBreakingTime(player, currentTime);

var pk1 = new LevelEventPacket();
pk1.setType(PARTICLE_CRACK_BLOCK);
var blockFaceOffset = Objects.requireNonNull(BlockFace.fromId(faceToBreak)).getOffset();
pk1.setPosition(Vector3f.from(blockToBreakX + 0.5f + blockFaceOffset.x(), blockToBreakY + 0.5f + blockFaceOffset.y(), blockToBreakZ + 0.5f + blockFaceOffset.z()));
var type = switch (Objects.requireNonNull(BlockFace.fromId(faceToBreak))) {
case UP -> PARTICLE_BREAK_BLOCK_UP;
case DOWN -> PARTICLE_BREAK_BLOCK_DOWN;
case NORTH -> PARTICLE_BREAK_BLOCK_NORTH;
case SOUTH -> PARTICLE_BREAK_BLOCK_SOUTH;
case WEST -> PARTICLE_BREAK_BLOCK_WEST;
case EAST -> PARTICLE_BREAK_BLOCK_EAST;
};
pk1.setType(type);
pk1.setPosition(Vector3f.from(blockToBreakX + 0.5f, blockToBreakY + 0.5f, blockToBreakZ + 0.5f));
pk1.setData(blockToBreak.blockStateHash());
player.getCurrentChunk().addChunkPacket(pk1);

var pk2 = new LevelEventPacket();
pk2.setType(BLOCK_UPDATE_BREAK);
pk2.setPosition(Vector3f.from(blockToBreakX, blockToBreakY, blockToBreakZ));
pk2.setData(toNetworkBreakTime(timeNeededToBreak));

player.getCurrentChunk().addChunkPacket(pk1);
player.getCurrentChunk().addChunkPacket(pk2);
}

Expand Down

0 comments on commit 444fe29

Please sign in to comment.