Skip to content

Test/feat plus fix#64

Open
TWME-TW wants to merge 10 commits intoTWME-TW:mainfrom
KoenLemmen:test/feat-plus-fix
Open

Test/feat plus fix#64
TWME-TW wants to merge 10 commits intoTWME-TW:mainfrom
KoenLemmen:test/feat-plus-fix

Conversation

@TWME-TW
Copy link
Owner

@TWME-TW TWME-TW commented Mar 9, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 9, 2026 05:04
Copy link

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 replaces the BlocketAPI-based fake barrier approach in freeze mode with physically placing BARRIER blocks on the server. It adds a FreezePacketLayer (using PacketEvents) to handle BLOCK_CHANGE packet interception for dependent neighbor blocks (like levers/rails attached to frozen blocks), and introduces FreezeBlockIsolationListener to prevent game events (explosions, physics, pistons, etc.) from affecting frozen or protected blocks. It also improves the right-click targeting logic in freeze mode to better handle FaceAttachable blocks.

Changes:

  • Replaced BlocketAPI fake-barrier mechanism with physical BARRIER block placement and a new packet interception layer (FreezePacketLayer) for protecting dependent neighbor blocks
  • Added FreezeBlockIsolationListener to cancel a comprehensive set of block events for frozen/protected locations (physics, explosions, piston, growth, decay, etc.)
  • Improved FreezeRightClick block targeting to properly detect and unfreeze frozen support blocks when clicking on FaceAttachable blocks (levers, buttons) attached to them

Reviewed changes

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

Show a summary per file
File Description
FreezePacketLayer.java New file: intercepts BLOCK_CHANGE and MULTI_BLOCK_CHANGE packets to restore protected dependent block states
FreezeBlockManager.java Major refactor: physically sets blocks to BARRIER on freeze, restores with BlockState, adds dependent neighbor snapshot/protection logic, removes BlocketAPI usage
FreezeBlockData.java Added originalState (BlockState) field and getter for more reliable block restoration
FreezeRightClick.java New resolveTargetBlock logic with FaceAttachable/Directional support; added null check for player
FreezeBlockIsolationListener.java New file: comprehensive Bukkit event listener cancelling all block-changing events for frozen/protected locations
PlayerDataManager.java playerRightClick signature updated to accept Action, Block, and BlockFace for contextual targeting
RightClickListener.java Passes click context (action, clickedBlock, blockFace) to PlayerDataManager.playerRightClick
LeftClickListener.java Removed unused imports (SendFakeBarrier, FreezeBlockManager, etc.)
BlockBreakEventListener.java Clears protectedDependentBlocks entry when a non-frozen block is broken
DebugStickPro.java Initializes/shuts down FreezePacketLayer; registers FreezeBlockIsolationListener; removes BlocketAPI init
SendFakeBarrier.java Deleted: entire class removed, replaced by physical BARRIER + packet layer approach
pom.xml Removed blocket-api dependency

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +112 to +115
private static String getExpectedData(World world, int x, int y, int z) {
Location location = new Location(world, x, y, z);
return FreezeBlockManager.getProtectedDependentData(location);
}
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The FreezePacketLayer listener intercepts BLOCK_CHANGE packets to protect dependent neighbor blocks (tracked in protectedDependentBlocks), but it does not intercept packets for the frozen blocks themselves. Frozen blocks are physically replaced with BARRIER on the server (line 58 in FreezeBlockManager), so if any plugin or server mechanism sends a BLOCK_CHANGE packet for a frozen location (e.g., during chunk re-sending, world restoration, or inter-plugin interaction), that packet will slip through and clients will see the wrong block state at the frozen location. Consider also intercepting BLOCK_CHANGE packets for locations that are in freezeBlockLocations by redirecting them to the BARRIER block state.

Copilot uses AI. Check for mistakes.
@EventHandler(ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
boolean protectedTarget = FreezeBlockManager.maintainProtectedDependent(event.getBlock());
boolean protectedSource = FreezeBlockManager.maintainProtectedDependent(event.getSourceBlock());
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

In onBlockPhysics, maintainProtectedDependent is called for both event.getBlock() and event.getSourceBlock() even when protectedTarget is already true. This means both blocks may have setBlockData(...) called on them during a single physics event unnecessarily. The maintainProtectedDependent(event.getSourceBlock()) call at line 28 can be skipped entirely if protectedTarget is already true since the event will be cancelled regardless. Consider short-circuit evaluation to avoid the redundant block modification.

Suggested change
boolean protectedSource = FreezeBlockManager.maintainProtectedDependent(event.getSourceBlock());
boolean protectedSource = !protectedTarget && FreezeBlockManager.maintainProtectedDependent(event.getSourceBlock());

Copilot uses AI. Check for mistakes.
Comment on lines +272 to +273
private static void registerProtectedDependentSnapshot(Map<FreezeLocation, String> snapshot) {
protectedDependentBlocks.putAll(snapshot);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

Entries added to protectedDependentBlocks via registerProtectedDependentSnapshot (after unfreezing a block) are never automatically removed once the temporary protection is no longer needed. They persist until the block is explicitly broken or replaced by a player. This causes a long-term stale protection issue: after a block is unfrozen, its former dependent neighbors (e.g., a lever, button, or rail) become permanently protected from physics events. For example, if a player later removes the support block for that lever legitimately, the onBlockPhysics event will still cancel the lever's fall because it remains in protectedDependentBlocks. Consider removing the snapshot entries from protectedDependentBlocks after the delayed restoration tasks (1-2 ticks) complete, keeping only the entries for blocks that are still in an inconsistent state after verification.

Copilot uses AI. Check for mistakes.
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.

3 participants