Hun Phan

Create a mod that allows you to pick up and restrain any mob by right-clicking on it, with the ability to mess with it; pressing the "Enter" key causes the mob's Belly to grow and inflate, becoming big, larger or massive with each press, and you can release the mob by right-clicking again.

Kodari AI
KodariOct 26 at 5:55 am 3
MobRestrainer
A Minecraft Fabric mod for version 1.21.4 that lets players pick up and restrain any mob by right-clicking it. While restrained, pressing the Enter key inflates the mob's belly, growing it progressively larger with each press. Right-clicking again releases the mob, restoring its original size. The mod provides an intuitive interaction system for capturing, inflating, and releasing mobs with visual feedback on the mob's size changes.
  • Add the Fabric mod entrypoints and a right-click pickup/release flow.

  • Add an Enter key action that inflates the held mob in escalating stages, with visible effects.

  • Check the 1.21.4 source signatures first, then create the complete project files.

Created the Fabric 1.21.4 mod. Right-click a living mob to hold it in front of you; right-click that mob again to release it. Press Enter to grow it and its visible belly, with growth increasing on each press until the scale limit. The mob’s original scale and movement settings are restored on release or server shutdown.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 440
src/main/java/com/kodari/mobrestraint/MobRestraintMod.java
package com.kodari.mobrestraint;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.player.UseEntityCallback;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;

public class MobRestraintMod implements ModInitializer {
    @Override
    public void onInitialize() {
        PayloadTypeRegistry.playC2S().register(InflatePayload.ID, InflatePayload.CODEC);

        UseEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            if (!(entity instanceof LivingEntity livingEntity) || entity instanceof PlayerEntity) {
                return ActionResult.PASS;
            }

            if (world.isClient) {
                return ActionResult.SUCCESS;
            }

            if (player instanceof ServerPlayerEntity serverPlayer) {
                HeldMobManager.toggle(serverPlayer, livingEntity);
            }
            return ActionResult.SUCCESS;
        });

        ServerPlayNetworking.registerGlobalReceiver(InflatePayload.ID, (payload, context) -> {
            if (payload.action() == 1 && payload.pressed()) {
                HeldMobManager.inflate(context.player());
            }
        });

        ServerTickEvents.END_SERVER_TICK.register(server -> HeldMobManager.tick());
        ServerLifecycleEvents.SERVER_STOPPING.register(server -> HeldMobManager.releaseAll());
    }
}