priyx.me

read it have promot

šŸ“Ž 1 file 3,396 chars
šŸ“„
pasted-code-1784993212564.txt
txt 111 lines
ā–¶
Create a Minecraft Java mod (Fabric, using Fabric API and Yarn mappings, 

targeting Minecraft 1.21.x) called "ChainBreak" with the following behavior:

CORE FEATURE:

When a player breaks a block, the mod should find all blocks of the SAME 

type that are directly or indirectly CONNECTED to the broken block (via 

face-adjacent neighbors — up/down/north/south/east/west, not diagonals) 

and break all of them too, dropping their normal items.

"Connected" means: starting from the broken block's position, do a 

flood-fill / BFS (breadth-first search) over the 6 face-adjacent neighbors. 

A neighbor is included only if it is the exact same Block type (e.g. 

minecraft:grass_block). The search continues recursively through all 

connected blocks of that type. Blocks of the same type that are NOT 

directly connected through a continuous chain of same-type blocks must 

NOT be broken — e.g. two separate grass patches with a stone gap between 

them should not both break, only the connected one.

IMPLEMENTATION DETAILS:

1. Listen to the PlayerBlockBreakEvents.AFTER event (Fabric API) to detect 

   when a block is broken by a player.

2. On break, capture the block's type (Block) and position (BlockPos) 

   BEFORE it's removed, then run BFS/flood-fill from that position.

3. Use a Queue and a Set (visited) to avoid 

   reprocessing positions and infinite loops.

4. For each connected block found, break it using world.breakBlock(pos, true) 

   so it drops items and plays break particles/sound, OR use 

   world.setBlockState(pos, Blocks.AIR.getDefaultState()) with manual 

   item drops if you want more control over drop stacking.

5. SAFETY / PERFORMANCE LIMITS:

   - Add a configurable max block limit per chain-break (default: 500) 

     to prevent lag or crashes on huge connected structures (e.g. an 

     entire ocean of water or a giant grass field).

   - Only search within currently loaded chunks (skip/stop expansion into 

     unloaded chunks) to avoid forcing chunk loads.

   - Run the flood-fill on the server thread; avoid blocking the main 

     tick thread for too long — consider batching over several ticks if 

     the block count is large, or run it in a way that's tick-safe.

6. Add a config option (via a simple JSON config or Fabric config API) to:

   - Enable/disable the mod

   - Set the max chain-break block limit

   - Provide a blacklist of block IDs that should NEVER chain-break 

     (e.g. bedrock, obsidian, or blocks like water/lava/leaves that could 

     cause huge cascades) — default blacklist should include unbreakable 

     blocks and liquids.

   - Optionally require the player to be holding a specific tool/item 

     (e.g. only chain-break when holding a special "Chain Pickaxe") 

     instead of always triggering.

7. Make sure creative mode instant-break also triggers the chain-break 

   (or make this toggleable in config).

8. Add appropriate logging (info-level) when a chain-break occurs, 

   including block type and count broken, for debugging.

DELIVERABLES:

- Full mod project structure (fabric.mod.json, build.gradle, 

  ChainBreakMod.java main class, config class, event listener class)

- Comments explaining the BFS logic

- A README with build/install instructions

Please write clean, well-organized Java code split into logical classes 

rather than one giant file.
Kodari AI
KodariJul 25 at 3:28 pm 8
ChainBreak
A Fabric 1.21.11 mod that automatically breaks face-connected blocks of the same type when a player breaks one of them. It uses a server-thread breadth-first flood-fill with configurable chain-size limits, loaded-chunk protection, enable and creative-mode toggles, block blacklists, optional required tool filtering, normal drops and effects, and informative logging. JSON configuration keeps behavior easy to customize without adding unnecessary dependencies.
  1. Project setup: create the Gradle/Fabric metadata and resource structure.

  2. Chain-break logic: add JSON configuration, event registration, loaded-chunk-safe BFS, filtering, breaking, and logging.

  3. Documentation: add a README with build, installation, and configuration instructions.

A Fabric 1.21.11 mod that automatically breaks face-connected blocks of the same type when a player mines one. It uses a server-side breadth-first flood fill with loaded-chunk checks and a configurable safety limit, supports creative mode and optional required tools, and provides a JSON configuration for enabling the feature and blacklisting dangerous blocks such as liquids, leaves, obsidian, and unbreakable blocks. Chain operations drop normal block items and are logged for administration and debugging.

તર

  1. Created the ChainBreak Fabric 1.21.11 project with Gradle, Yarn mappings, Fabric API, and Java 21 configuration.

  2. Added server-side BFS chain breaking with loaded-chunk checks, configurable limits, creative-mode support, tool requirements, blacklist handling, normal drops, and logging.

  3. Added JSON configuration management at config/chainbreak.json.

  4. Added README instructions for building, installation, and configuration.

Kodari can make mistakes. Review important code before using.
Files
src
.gitignore
build.gradle
gradle.properties
README.md
settings.gradle
Code
10 439
src/main/java/com/kodari/chainbreak/ChainBreakMod.java
package com.kodari.chainbreak;

import com.kodari.chainbreak.config.ConfigManager;
import com.kodari.chainbreak.event.ChainBreakListener;
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ChainBreakMod implements ModInitializer {
    public static final String MOD_ID = "chainbreak";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {
        ConfigManager.load();
        ChainBreakListener.register();
        LOGGER.info("ChainBreak initialized");
    }
}