Build a Minecraft Bukkit/Spigot plugin named Instant Happy Ghasts. Feature: when a Dried Ghast is placed in water and normally begins its hydration/growth process, make the full progression instantaneous: it should immediately become a Ghastling and then immediately a fully grown Happy Ghast, rather than waiting through the default growth stages. Implement using the project's configured API/version and appropriate Bukkit events/API. Ensure it works whether the block is hydrated by placement into water or water flowing onto it, as applicable. Handle relevant lifecycle/event ordering safely, avoid duplicate entities, and preserve normal behavior for unrelated blocks/entities. Include plugin metadata and any necessary configuration only if consistent with the existing project template. Make the feature robust on the supported server version. Do not add tests. Do not attempt to build/compile; the workspace will compile after your changes.

Kodari AI
KodariOct 31 at 6:37 pm 1
InstantHappyGhasts
Minecraft Bukkit plugin that accelerates Dried Ghast hydration. When a Dried Ghast block is placed in water or water flows onto it, the plugin instantly completes the growth progression: the Dried Ghast immediately becomes a Ghastling, which then immediately transforms into a fully grown Happy Ghast. Uses block physics events to detect hydration triggers, safely manages entity spawning to prevent duplicates, and preserves normal behavior for all other blocks and entities. Handles both direct water placement and water flow scenarios through robust event handling.

I’ll target Spigot 1.21.6 and add water-placement/flow detection that replaces a hydrated Dried Ghast with a Ghastling, then a Happy Ghast one tick later.

Implemented Instant Happy Ghasts for Spigot 1.21.6. Water placement and flow trigger a nearby Dried Ghast to become a Ghastling, then a Happy Ghast on the next tick. Duplicate triggers are suppressed, and the block is restored if the Ghastling cannot spawn.

Fix the reported bug: placing a Dried Ghast in water does not immediately turn it into a Ghastling. Read and revise the existing InstantHappyGhastsPlugin.java implementation rather than adding a parallel implementation. Diagnose the trigger/contact issue (current code listens to BlockPlaceEvent and BlockFromToEvent, then only checks face-adjacent blocks named WATER and schedules one tick later). Ensure the plugin reliably detects a Dried Ghast being placed in or becoming surrounded by water, including the actual placement/flow event ordering and water at the relevant block position if applicable, then immediately removes the block and spawns a GHASTLING followed by the existing instant Happy Ghast progression. Keep safeguards against duplicate spawns and avoid affecting unrelated blocks. Make spawn failure handling safe and preserve the dried block if no entity can be spawned. Do not add tests and do not attempt to build.

Kodari AI
KodariOct 31 at 6:47 pm 1
  • Capture water replaced during Dried Ghast placement so the block can still be recognized after placement overwrites that water.

  • Detect water in the block itself or any adjacent position, and defer flow checks until the flow event has completed.

  • Keep duplicate suppression and restore the Dried Ghast if Ghastling spawning fails.

Updated InstantHappyGhastsPlugin.java: placement now remembers if water occupied the placed block’s position, and water-flow checks detect Dried Ghasts throughout the surrounding 3×3×3 area after the event completes. Waterlogged blocks count as water, duplicate triggers remain suppressed, and a failed Ghastling spawn restores the Dried Ghast. The Ghastling-to-Happy-Ghast progression is unchanged.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 181
src/main/java/com/kodari/instanthappyghasts/InstantHappyGhastsPlugin.java
package com.kodari.instanthappyghasts;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public final class InstantHappyGhastsPlugin extends JavaPlugin implements Listener {
    private static final String DRIED_GHAST = "DRIED_GHAST";
    private static final String WATER = "WATER";
    private final Set<String> scheduledBlocks = new HashSet<>();

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onBlockPlace(BlockPlaceEvent event) {
        Block placed = event.getBlockPlaced();
        scheduleNearbyDriedGhasts(placed, isWater(event.getBlockReplacedState()));
    }

    @EventHandler
    public void onWaterFlow(BlockFromToEvent event) {
        if (!isWater(event.getBlock())) {
            return;
        }

        scheduleNearbyDriedGhasts(event.getBlock(), false);
        scheduleNearbyDriedGhasts(event.getToBlock(), isWater(event.getToBlock()));
    }

    private void scheduleNearbyDriedGhasts(Block center, boolean waterAtCenter) {
        scheduleIfDriedGhast(center, waterAtCenter);
        for (int x = -1; x <= 1; x++) {
            for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                    if (x == 0 && y == 0 && z == 0) {
                        continue;
                    }
                    scheduleIfDriedGhast(center.getRelative(x, y, z), false);
                }
            }
        }
    }

    private void scheduleIfDriedGhast(Block block, boolean waterAtPosition) {
        if (!isDriedGhast(block)) {
            return;
        }

        String key = blockKey(block);
        if (!scheduledBlocks.add(key)) {
            return;
        }

        Bukkit.getScheduler().runTaskLater(this, () -> {
            scheduledBlocks.remove(key);
            if (isDriedGhast(block) && (waterAtPosition || hasWaterContact(block))) {
                growGhast(block);
            }
        }, 1L);
    }

    private boolean isDriedGhast(Block block) {
        return DRIED_GHAST.equals(block.getType().name());
    }

    private boolean hasWaterContact(Block block) {
        if (isWater(block)) {
            return true;
        }

        for (int x = -1; x <= 1; x++) {
            for (int y = -1; y <= 1; y++) {
                for (int z = -1; z <= 1; z++) {
                    if ((x != 0 || y != 0 || z != 0) && isWater(block.getRelative(x, y, z))) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    private boolean isWater(Block block) {
        return WATER.equals(block.getType().name())
                || block.getBlockData() instanceof Waterlogged waterlogged && waterlogged.isWaterlogged();
    }

    private boolean isWater(BlockState state) {
        return WATER.equals(state.getType().name())
                || state.getBlockData() instanceof Waterlogged waterlogged && waterlogged.isWaterlogged();
    }

    private void growGhast(Block block) {
        World world = block.getWorld();
        Location location = block.getLocation().add(0.5, 1.0, 0.5);
        block.setBlockData(Bukkit.createBlockData("minecraft:air"), false);

        Entity ghastling = spawn(world, location, "GHASTLING");
        if (ghastling == null || !ghastling.isValid()) {
            restoreDriedGhast(block);
            return;
        }

        Bukkit.getScheduler().runTask(this, () -> {
            if (!ghastling.isValid() || ghastling.isDead()) {
                return;
            }

            Location grownLocation = ghastling.getLocation();
            Entity happyGhast = spawn(world, grownLocation, "HAPPY_GHAST");
            if (happyGhast != null && happyGhast.isValid()) {
                ghastling.remove();
            }
        });
    }

    private Entity spawn(World world, Location location, String typeName) {
        try {
            return world.spawnEntity(location, EntityType.valueOf(typeName));
        } catch (RuntimeException exception) {
            getLogger().warning("Could not spawn " + typeName + ": " + exception.getMessage());
            return null;
        }
    }

    private void restoreDriedGhast(Block block) {
        if (block.getType().isAir()) {
            block.setBlockData(Bukkit.createBlockData("minecraft:dried_ghast"), false);
        }
    }

    private String blockKey(Block block) {
        UUID worldId = block.getWorld().getUID();
        return worldId + ":" + block.getX() + ":" + block.getY() + ":" + block.getZ();
    }
}