The provided code is a module for the Minecraft Meteor...
The provided code is a module for the Minecraft Meteor Client, a utility modification for the game. This module is designed to target players who are swimming and tries to prevent them from standing up by placing blocks above them. Here's what the code does:
-
Initialization (
ForceSwim
Constructor):- Registers the module under the "Combat" category with the name "force-swim" and a brief description.
- Allows users to configure settings such as block whitelist, targeting range, target priority, rendering behavior, and block placement visuals.
-
Settings:
- General settings:
blocks
: A whitelist of blocks (default: Obsidian, Netherite Block) that can be placed to prevent swimming players from standing up.range
: The range within which the module can target players.priority
: The priority method used to select a target (e.g., players with the lowest health).pauseEat
: Pauses the block placement logic if the user is eating.
- Rendering settings:
render
: Whether or not the module visually renders placement positions.shapeMode
: The style of rendering (e.g., solid, outline, or a combination of both).sideColor
andlineColor
: Colors used for rendering overlays on placement locations.
- General settings:
-
Activation and Deactivation:
- Resets the target to
null
when the module is activated. - Does nothing when deactivated.
- Resets the target to
-
Player Targeting and Block Placement (
onTick
Event Handler):- Continuously checks for and targets a nearby player within the configured range who is swimming (crawling).
- Skips block placement if:
- The player’s target is invalid or out of range.
- The user is eating and the
pauseEat
setting is enabled. - The required blocks are not found in the user's inventory.
- Gets a list of positions above the target player where blocks can be placed.
- Places blocks at valid positions (except where an adjacent block may cause issues, such as near horizontal crystal placements).
-
Block Selection (
findUseItem
Method):- Searches for the allowed blocks (as per the whitelist) in the user's inventory and returns the block to use for placement.
-
Calculated Block Positions (
getBlockPoses
Method):- Computes a list of block positions above the target player’s position based on their bounding box.
-
Rendering (
onRender
Event Handler):- If rendering is enabled, visualizes the block placement positions (e.g., outlines or fill color) for the target player.
- Skips rendering for invalid placement positions or blocks near horizontal adjacent positions.
-
Additional Functionality:
- Displays the targeted player's name via
getInfoString()
.
- Displays the targeted player's name via
Summary:
The ForceSwim
module in the Meteor Client is designed to target swimming (crawling) players and block them from standing up by strategically placing blocks above them. It includes settings for configuring targeting logic, block types, placement range, and visual rendering. The code monitors player actions and periodically calculates valid placement positions in real-time, rendering block overlays when rendering is enabled.