nepaayuz
šŸ“Ž 1 file 6,172 chars
šŸ“„
BlockInfection-1.21.11-prompt.md
md 129 lines
ā–¶
Build a Paper/Spigot Minecraft plugin called "BlockInfection" targeting server
version 1.21.11 (api-version '1.21' in plugin.yml, paper-api dependency pinned
to 1.21.11-R0.1-SNAPSHOT). Java 21. Package it as a Maven project with the
shade plugin so dependencies are bundled into the final jar.

## Core concept: virus-style block spreading

When a player breaks a block that belongs to a configured category
(EASY / NORMAL / HARD block lists in config.yml), trigger an "infection":

1. Roll a weighted random outcome category from chances.EASY / chances.NORMAL
   / chances.HARD / chances.SPAWNER (percentages configurable, should sum to
   100 by default: EASY 2, NORMAL 25, HARD 23, SPAWNER 50). The outcome
   category can differ from the source category.
2. If the outcome is SPAWNER, pick a random mob from a configurable
   spawner.mobs list and the result becomes a spawner block set to that mob.
   Otherwise pick a random block material from that category's block list in
   config.yml.
3. Do NOT do a connected-blocks flood fill. Instead spread to a random
   number of blocks scattered around the broken block, with NO requirement
   that they touch each other or the origin block:
   - Total blocks to infect: random between min-blocks and max-blocks
     (config, default 50-500).
   - The search box around the origin is asymmetrical/organic: each of the
     6 directions (+X, -X, +Y, -Y, +Z, -Z) independently rolls its own
     random radius between min-radius and max-radius (config, default
     50-100 blocks), instead of one uniform cube radius.
   - Targets are picked by choosing random offsets within that box and
     checking the real block there — only existing SOLID blocks are ever
     converted (never place into air or liquid; skip and re-roll if the
     target is air/liquid/already infected).
4. Apply the spread gradually over time instead of instantly: convert a
   configurable number of blocks per batch (blocks-per-batch, default 4)
   every N ticks (ticks-per-batch, default 2), using a BukkitRunnable /
   scheduler task, to avoid lag spikes on large spreads. Cap total random
   target attempts at (remaining blocks * max-attempts-multiplier) so it
   can't spin forever if it runs out of valid targets.
5. Track every block that has been produced by a spread (world+x+y+z) in an
   in-memory set. If a player breaks a block that's in this set, it must
   NEVER start a new infection — treat it as a plain break. Any block NOT
   in this set is always eligible to start a fresh, independent infection
   when broken, even if it's sitting right next to already-infected blocks.
6. infection.prevent-recursion (config, default true) toggles the immunity
   check above. infection.preserve-drops (default true) controls whether
   the originally broken block still drops its normal items — blocks
   converted during the spread itself never drop anything, they just
   silently change type.

## Commands
/infection 
permission: blockinfection.admin (default: op)

- on/off: toggle the plugin, persist to config.yml
- status: show current on/off state
- reload: reload config.yml and clear the infected-blocks tracking set
- chat: toggle whether infection start/result messages are sent to the
  triggering player
- chance  <0-100> (alias: percentage): set one category's chance
- chances: print all four current chance values
- spread: with no extra args, print current spreading settings; with
  `spread  `, update one of: min-blocks, max-blocks,
  min-radius, max-radius, blocks-per-batch, ticks-per-batch (positive
  integers only)

Include tab completion for all subcommands and their arguments.

## config.yml structure
```
enabled: false
debug: false
chat:
  enabled: true
chances:
  EASY: 2
  NORMAL: 25
  HARD: 23
  SPAWNER: 50
infection:
  prevent-recursion: true
  preserve-drops: true
spreading:
  min-blocks: 50
  max-blocks: 500
  min-radius: 50
  max-radius: 100
  blocks-per-batch: 4
  ticks-per-batch: 2
  max-attempts-multiplier: 20
  require-solid-target: true
spawner:
  mobs: [ZOMBIE, SKELETON, CREEPER, SPIDER, BLAZE, ENDERMAN, WARDEN]
blocks:
  EASY: [STONE, COBBLESTONE, DIRT, GRASS_BLOCK, SAND, GRAVEL, OAK_LOG,
         OAK_LEAVES, BIRCH_LOG, SPRUCE_LOG, GLASS, BRICKS]
  NORMAL: [COAL_ORE, IRON_ORE, COPPER_ORE, REDSTONE_ORE, LAPIS_ORE,
           QUARTZ_BLOCK, AMETHYST_BLOCK, OBSIDIAN, IRON_BLOCK, COPPER_BLOCK]
  HARD: [DIAMOND_BLOCK, GOLD_BLOCK, EMERALD_BLOCK, NETHERITE_BLOCK,
         ANCIENT_DEBRIS, CRYING_OBSIDIAN]
messages:
  (prefix + all command feedback strings + infection.started /
   infection.result chat messages, with color codes via &)
```

## Classes to produce
- Category enum (EASY, NORMAL, HARD, SPAWNER) with fromName(String)
- BlockPosition: immutable world-UUID + x/y/z key with equals/hashCode, used
  both for the infected-blocks tracking set and general position identity
- InfectionResult: holds either a chosen Material or (Material.SPAWNER +
  EntityType), with a resultName() for messages
- InfectionEngine: owns the infected-blocks Set, listens via a
  BlockBreakEvent handler, does the category lookup, weighted chance roll,
  result creation, and kicks off the gradual spread job; exposes
  clearProcessingGuard() for /infection reload
- SpreadJob (BukkitRunnable): performs the asymmetrical radius rolls per
  axis, the batched random-target conversion loop, solid-block checks,
  spawner setup via CreatureSpawner, and sends the "infection finished"
  chat message when done
- InfectionListener: thin @EventHandler(priority=HIGHEST,
  ignoreCancelled=true) wrapper calling engine.process(event)
- InfectionCommand: CommandExecutor + TabCompleter implementing all
  subcommands above
- BlockInfectionPlugin (main class): loads config, tracks enabled state,
  registers listener/command, exposes message()/rawMessage()/debug() helpers

Deliver a working Maven project (pom.xml with paper-api provided scope
pinned to 1.21.11-R0.1-SNAPSHOT, maven-shade-plugin configured) plus all
source files and the default config.yml/plugin.yml, so `mvn package`
produces the finished plugin jar.
Kodari AI
KodariSep 3 at 11:34 am 2
BlockInfection
A Minecraft plugin introducing virus-style block spreading. When players break blocks from configured categories, it triggers weighted random infections that convert scattered solid blocks into new materials or mob spawners. Spreads occur gradually in batched scheduler tasks across asymmetrical search boxes, with recursion prevention and configurable chances, radii, and batch sizes. Includes admin commands for toggling, reloading, and adjusting all settings.
  1. Create the Maven project and plugin metadata for Paper 1.21.11.

  2. Implement infection data types, weighted outcome selection, tracking, and gradual spread jobs.

  3. Add admin commands, tab completion, runtime configuration handling, and default messages/settings.

  1. Created the Maven Paper 1.21.11 project with Java 21, shaded dependencies, plugin.yml, and default config.yml.

  2. Implemented infection categories, immutable block positions, weighted outcomes, configurable mob spawners, recursion protection, drop preservation, and gradual asynchronous spreading.

  3. Added admin commands with persistence and tab completion: /infection on|off|status|reload|chat|chance|percentage|chances|spread.

  4. Added configurable messages, debug logging, asymmetric search radii, batch limits, attempt caps, and infected-block tracking.

nepaayuz

fix all the bugs

Kodari AI
KodariSep 3 at 11:50 am 2
  1. Harden lifecycle and command registration.

  2. Make chance selection, job startup, and configuration handling fail-safe.

  3. Prevent scheduler exceptions and coordinate/range overflow in spread jobs.

  4. Fix command validation and usage/tab-completion inconsistencies.

[Generation stopped]

nepaayuz

spreading block is unsymmetircal but not in gap block must spread but in same chunk Same connected block

Kodari AI
KodariSep 3 at 11:52 am 1
  1. Change spread selection from scattered targets to connected neighbors within the origin chunk.

  2. Preserve asymmetrical per-axis radius behavior while preventing gaps and cross-chunk conversion.

  3. Keep batching, infection tracking, spawner setup, and completion messaging intact.

Updated spreading behavior:

  • Infection now spreads through connected neighboring blocks instead of randomly jumping across gaps.

  • All infected blocks remain within the same chunk as the originally broken block.

  • The six-direction spread remains asymmetrical using independently rolled radii.

  • Air, liquids, non-solid blocks, infected blocks, and blocks outside the radius are skipped.

  • Batched spreading, recursion prevention, spawner conversion, and infection tracking remain intact.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
11 971
src/main/java/com/kodari/blockinfection/BlockInfectionPlugin.java
package com.kodari.blockinfection;

import org.bukkit.ChatColor;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class BlockInfectionPlugin extends JavaPlugin {
    private InfectionEngine infectionEngine;
    private boolean enabled;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadSettings();

        infectionEngine = new InfectionEngine(this);
        getServer().getPluginManager().registerEvents(new InfectionListener(infectionEngine), this);

        PluginCommand command = getCommand("infection");
        if (command == null) {
            throw new IllegalStateException("The infection command is missing from plugin.yml");
        }
        InfectionCommand infectionCommand = new InfectionCommand(this, infectionEngine);
        command.setExecutor(infectionCommand);
        command.setTabCompleter(infectionCommand);
    }

    @Override
    public void onDisable() {
        if (infectionEngine != null) {
            infectionEngine.shutdown();
        }
    }

    public void loadSettings() {
        enabled = getConfig().getBoolean("enabled", false);
    }

    public void reloadSettings() {
        reloadConfig();
        loadSettings();
    }

    public boolean isInfectionEnabled() {
        return enabled;
    }

    public void setInfectionEnabled(boolean enabled) {
        this.enabled = enabled;
        getConfig().set("enabled", enabled);
        saveConfig();
    }

    public InfectionEngine getInfectionEngine() {
        return infectionEngine;
    }

    public String rawMessage(String path) {
        return getConfig().getString("messages." + path, path);
    }

    public String message(String path, Object... replacements) {
        String message = rawMessage(path);
        String prefix = rawMessage("prefix");
        if (!path.equals("prefix")) {
            message = prefix + message;
        }
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            String key = String.valueOf(replacements[index]);
            String value = String.valueOf(replacements[index + 1]);
            message = message.replace("{" + key + "}", value);
        }
        return ChatColor.translateAlternateColorCodes('&', message);
    }

    public void debug(String message) {
        if (getConfig().getBoolean("debug", false)) {
            getLogger().info("[Debug] " + message);
        }
    }
}