Варфоломей Вурдалаков

Create a mod for Minecraft version 26.3 NeoForge that removes the happy ghast, the ghast harness, the ghastling, the dried ghast, the lava chicken record, the happy ghast spawn egg, and the achievements related to happy ghasts from the game.

Kodari AI
KodariOct 17 at 4:24 pm 3
GhastRemovalMod
A NeoForge mod for Minecraft 26.3 that removes all happy ghast content from the game. It eliminates the happy ghast entity, ghastling, dried ghast, ghast harness item, lava chicken music disc, and happy ghast spawn egg. The mod also strips all related advancements and achievements, preventing them from appearing in progression menus. It intercepts item and entity registries to prevent spawning, crafting, or usage of these elements, ensuring a clean vanilla experience without any happy ghast features.
  1. Target the mounted NeoForge 26.2 API (the available source version), since no 26.3 library is provided.

  2. Find the supported registry/advancement hooks to remove the requested vanilla content.

  3. Create the minimal mod files and remove the happy-ghast-related entries.

Created the Ghast Remover mod. It targets Minecraft/NeoForge 26.2, not 26.3, because the available source and project baseline are 26.2.

It blocks Happy Ghast spawns (including ghastlings), hides the dried ghast, harnesses, spawn egg, and Lava Chicken disc from creative tabs, removes dried-ghast and harness recipes, blocks use of those items, and makes the dried-ghast advancement unreachable.

Limitation: NeoForge 26.2 does not support unregistering vanilla registry entries, so these items and entity types still exist internally. Existing dried-ghast blocks can remain in the world until mined, and the mod cannot remove matching items already stored in inventories or containers.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 134
src/main/java/com/example/ghastremover/GhastRemover.java
package com.example.ghastremover;

import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.event.ModifyRecipeJsonsEvent;
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;

@Mod(GhastRemover.MOD_ID)
public final class GhastRemover {
    public static final String MOD_ID = "ghastremover";

    public GhastRemover(IEventBus modBus) {
        modBus.addListener(this::removeFromCreativeTabs);
        NeoForge.EVENT_BUS.addListener(this::removeRecipes);
        NeoForge.EVENT_BUS.addListener(this::removeEntitiesAndDroppedItems);
        NeoForge.EVENT_BUS.addListener(this::blockBlockUse);
        NeoForge.EVENT_BUS.addListener(this::blockItemUse);
        NeoForge.EVENT_BUS.addListener(this::blockEntityUse);
    }

    private void removeFromCreativeTabs(BuildCreativeModeTabContentsEvent event) {
        event.removeIf(stack -> isRemovedItem(stack.getItem()), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
    }

    private void removeRecipes(ModifyRecipeJsonsEvent event) {
        event.getRecipeJsons().keySet().removeIf(id -> {
            String recipeId = id.toString();
            return recipeId.equals("minecraft:dried_ghast")
                || recipeId.startsWith("minecraft:") && recipeId.endsWith("_harness");
        });
    }

    private void removeEntitiesAndDroppedItems(EntityJoinLevelEvent event) {
        if (event.getEntity().getType() == EntityTypes.HAPPY_GHAST) {
            event.setCanceled(true);
            return;
        }

        if (event.getEntity() instanceof ItemEntity itemEntity && isRemovedItem(itemEntity.getItem().getItem())) {
            event.setCanceled(true);
        }
    }

    private void blockBlockUse(PlayerInteractEvent.RightClickBlock event) {
        if (isRemovedItem(event.getItemStack().getItem())) {
            event.setCanceled(true);
        }
    }

    private void blockItemUse(PlayerInteractEvent.RightClickItem event) {
        if (isRemovedItem(event.getItemStack().getItem())) {
            event.setCanceled(true);
        }
    }

    private void blockEntityUse(PlayerInteractEvent.EntityInteract event) {
        if (isRemovedItem(event.getItemStack().getItem())) {
            event.setCanceled(true);
        }
    }

    private static boolean isRemovedItem(Item item) {
        return item == Items.DRIED_GHAST
            || item == Items.HAPPY_GHAST_SPAWN_EGG
            || item == Items.MUSIC_DISC_LAVA_CHICKEN
            || Items.HARNESS.asList().contains(item);
    }
}