The provided code is a module for the Minecraft Meteor...

January 11, 2025 at 04:46 AM

/* * This file is part of the Meteor Client distribution * (https://github.com/MeteorDevelopment/meteor-client). Copyright (c) Meteor Development. */ package meteordevelopment.meteorclient.systems.modules.combat; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.TargetUtils; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import java.util.ArrayList; import java.util.List; public class ForceSwim extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgRender = settings.createGroup("Render"); // General private final Setting<List<Block>> blocks = sgGeneral.add( new BlockListSetting.Builder().name("whitelist").description("Which blocks to use.") .defaultValue(Blocks.OBSIDIAN, Blocks.NETHERITE_BLOCK).build()); private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder().name("target-range") .description("The range players can be targeted.").defaultValue(4).build()); private final Setting<SortPriority> priority = sgGeneral.add(new EnumSetting.Builder<SortPriority>().name("target-priority") .description("How to select the player to target.") .defaultValue(SortPriority.LowestHealth).build()); private final Setting<Boolean> pauseEat = sgGeneral.add(new BoolSetting.Builder() .name("pause-eat").description("Pauses while eating.").defaultValue(true).build()); // Render private final Setting<Boolean> render = sgRender.add(new BoolSetting.Builder().name("render") .description("Renders an overlay where blocks will be placed.").defaultValue(true) .build()); private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>() .name("shape-mode").description("How the shapes are rendered.") .defaultValue(ShapeMode.Both).build()); private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder() .name("side-color").description("The side color of the target block rendering.") .defaultValue(new SettingColor(197, 137, 232, 10)).build()); private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder() .name("line-color").description("The line color of the target block rendering.") .defaultValue(new SettingColor(197, 137, 232)).build()); private PlayerEntity target; public ForceSwim() { super(Categories.Combat, "force-swim", "Tries to prevent people from standing up while swiming"); } @Override public void onActivate() { target = null; } @Override public void onDeactivate() { } @EventHandler private void onTick(TickEvent.Pre event) { if (target == null || TargetUtils.isBadTarget(target, range.get())) { target = TargetUtils.getPlayerTarget(range.get(), priority.get()); if (TargetUtils.isBadTarget(target, range.get())) return; } if (target == null || !target.isCrawling()) { return; } if (pauseEat.get() && mc.player.isUsingItem()) { return; } Item useItem = findUseItem(); if (useItem == null) { return; } List<BlockPos> placePoses = getBlockPoses(); if (!MeteorClient.BLOCK.beginPlacement(placePoses, useItem)) { return; } placePoses.forEach(blockPos -> { boolean isCrystalBlock = false; for (Direction dir : Direction.Type.HORIZONTAL) { if (blockPos.equals(target.getBlockPos().offset(dir))) { isCrystalBlock = true; } } if (isCrystalBlock) { return; } MeteorClient.BLOCK.placeBlock(Items.OBSIDIAN, blockPos); }); MeteorClient.BLOCK.endPlacement(); } private Item findUseItem() { FindItemResult result = InvUtils.findInHotbar(itemStack -> { for (Block blocks : blocks.get()) { if (blocks.asItem() == itemStack.getItem()) { return true; } } return false; }); if (!result.found()) { return null; } return mc.player.getInventory().getStack(result.slot()).getItem(); } private List<BlockPos> getBlockPoses() { List<BlockPos> list = new ArrayList<>(); Box boundingBox = target.getBoundingBox().expand(0.7, 0.0, 0.7); double feetY = target.getY(); Box feetBox = new Box(boundingBox.minX, feetY, boundingBox.minZ, boundingBox.maxX, feetY + 0.1, boundingBox.maxZ); for (BlockPos pos : BlockPos.iterate((int) Math.floor(feetBox.minX), (int) Math.floor(feetBox.minY), (int) Math.floor(feetBox.minZ), (int) Math.floor(feetBox.maxX), (int) Math.floor(feetBox.maxY), (int) Math.floor(feetBox.maxZ))) { list.add(pos.add(0, 1, 0)); } return list; } @EventHandler private void onRender(Render3DEvent event) { if (!render.get()) return; if (target == null || !target.isCrawling()) { return; } List<BlockPos> poses = getBlockPoses(); for (BlockPos pos : poses) { boolean isCrystalBlock = false; for (Direction dir : Direction.Type.HORIZONTAL) { if (pos.equals(target.getBlockPos().offset(dir))) { isCrystalBlock = true; } } if (isCrystalBlock) { continue; } if (BlockUtils.canPlace(pos, true)) { event.renderer.box(pos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); } } } @Override public String getInfoString() { return EntityUtils.getName(target); } }

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:

  1. 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.
  2. 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 and lineColor: Colors used for rendering overlays on placement locations.
  3. Activation and Deactivation:

    • Resets the target to null when the module is activated.
    • Does nothing when deactivated.
  4. 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).
  5. 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.
  6. Calculated Block Positions (getBlockPoses Method):

    • Computes a list of block positions above the target player’s position based on their bounding box.
  7. 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.
  8. Additional Functionality:

    • Displays the targeted player's name via getInfoString().

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.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node