no_nameaccount

Create a mod that add block like a computer named "Console" when you click it its gives any item that you write but soon you will realise that items you writed dissapeared from the world and you have only that last item

Kodari AI
KodariJun 3 at 9:35 am 24
ConsoleBlock
A Fabric 1.21.11 mod adding a "Console" block. Right-click it to open a terminal-style GUI where you type any item ID to instantly receive that item. The twist: every time you request a new item, ALL previously Console-given items vanish from your inventory AND the world — you can only ever hold the last thing you asked for. A creepy, mysterious block that giveth and taketh away.

Plan:

  • ConsoleBlock — plain block, on use sends S2C packet to open screen

  • OpenConsolePayload (S2C) + RequestItemPayload (C2S) — networking

  • Server handler: marks given items with CUSTOM_DATA, clears all marked items from inventory + world, then gives the new one

  • ConsoleScreen — text field + button client-side screen

  • Block model reusing vanilla command_block texture for a techy look


Here’s how the mod works:

Mechanics:

  • Place the Console block and right-click it to open the terminal GUI

  • Type any item ID (e.g. diamond, minecraft:netherite_sword, iron_ingot) and press Enter or REQUEST

  • You instantly receive that item — but every previously Console-given item vanishes, from both your inventory and any item entities within 512 blocks of you

  • You can only ever possess the last item you asked for

The horror loop: Ask for a sword → get it. Ask for food → sword disappears, get bread. Ask for torches → bread disappears. You can never accumulate anything from the Console.

Getting the block: /give @s consolemod:console — no crafting recipe by design, keeping it mysterious.

no_nameaccount

change the name consolemod to theconsole

Kodari AI
KodariJun 3 at 9:40 am 13

The resource paths and fabric.mod.json are already on theconsole. I just need to fix the Java package declarations and the MOD_ID constant — they still say consolemod.

All references to consolemod are now theconsole — package declarations, MOD_ID, and the lang key.

no_nameaccount

add crafting recipe that using 1 glass pane 5 white concrete and 3 oak log

Kodari AI
KodariJun 3 at 9:41 am 3

The layout is: 1 glass pane on top-center, 5 white concrete filling the sides + bottom, 3 oak logs across the middle row.

Plain Text
[ ][ G ][ ]
[ O ][ O ][ O ]
[ C ][ C ][ C ]

Wait, that’s only 2 concrete. Let me use a proper 3×3:

Plain Text
C  G  C
O  O  O
C  W  C

— 4 concrete + 1 glass + 3 logs + 1 concrete = 5 concrete total. ✓

The pattern uses:

  • G = glass pane (top-center)

  • O = oak log × 3 (middle row)

  • C = white concrete × 5 (top-left, top-right, bottom row of 3)

no_nameaccount

add block broken console that change block console when you are requesting barrier,command block,repeating command block

Kodari AI
KodariJun 3 at 9:45 am 23

Now I have everything I need. Here’s the plan:

  • Add BrokenConsoleBlock (inert — no GUI, just sits there)

  • Register it in ModBlocks

  • In ConsoleMod server handler, detect the 3 forbidden items and replace the console block in the world with broken console

  • Add blockstate, model, item model, lang, and assets

First, I need to know the player’s block position — the payload needs to carry it. I’ll add blockPos to RequestItemPayload.

I also need to send the block position from client → server. I’ll update OpenConsolePayload to carry the pos, RequestItemPayload to carry the pos, the block’s onUse to include pos in the open payload, and the screen to send it back.

Now I have everything. Here’s my approach:

  • Add BlockPos to OpenConsolePayload (server → client, so client screen knows which block)

  • Add BlockPos to RequestItemPayload (client → server)

  • Create BrokenConsoleBlock

  • Register it in ModBlocks

  • Server handler detects barrier/command_block/repeating_command_block → replace world block with broken console

  • Add all assets

Now update the screen to store the block pos and send it back, update ModBlocks to register BROKEN_CONSOLE, update ConsoleMod to handle the replacement, and create all the new files.

Now update ModBlocks to add BROKEN_CONSOLE, update ConsoleMod to handle the replacement logic, and create all asset files.

Now create the BrokenConsoleBlock class and all the asset files:

Now fix the blockstates for console which still had the wrong mod ID:

Now add the lang entries and the BrokenConsoleBlock files:


Here’s what was added:

Broken Console block:

  • Uses the vanilla crying_obsidian texture — dark, cracked, clearly damaged

  • When right-clicked it only prints §4[Console] SYSTEM FAILURE — this unit is permanently offline. and does nothing else

  • Cannot be interacted with further

Trigger items — requesting any of these transforms the Console into a Broken Console in-place:

  • minecraft:barrier

  • minecraft:command_block

  • minecraft:repeating_command_block

The player gets a red ERROR — SYSTEM FAILURE message and no item. The block swap is permanent — the only way to get a working Console back is to replace it with a new one.

no_nameaccount

change ConsoleMod Handler to the TheConsole and ModBlocks To the Blocks

Kodari AI
KodariJun 3 at 9:45 am 2
no_nameaccount

Add Console Fixer Item that can fix broken console 1 time per use. If you broke it again then its dissapearing and saying red text "CONSOLE BLOCKED" and it cant be craftable anymore

Kodari AI
KodariJun 3 at 9:49 am 17

Now I have everything I need. Here’s the plan:

  • ConsoleFixer item: first use on BrokenConsoleBlock → restores console, marks item fixer_used=true; second use (already marked) → item disappears, sends red §4CONSOLE BLOCKED

  • Register in Blocks.java, add item model, lang, and crafting recipe

Now create the item class and all assets:

Now write the actual ConsoleFixer item class and asset files:

Console Fixer crafted with diamond center, iron ingots on the sides, glass panes on corners.

Behavior:

  • Right-click a Broken Console → restores it to a normal Console, item is now marked as used

  • Right-click a Broken Console again with the used fixer → item is consumed (disappears), player sees §4CONSOLE BLOCKED, console stays broken permanently

no_nameaccount

change how fixer works. If you broke console 2nd time by typing command block, barrier, repeating command block, then its showing red text in chat CONSOLE BLOCKED. And all consoles: Broken Console , Console, Console Fixer will dissapear and cant be crafted and used in creative mode.

no_nameaccount

change how fixer works. If you broke console 2nd time by typing command block, barrier, repeating command block, then its showing red text in chat CONSOLE BLOCKED. And all consoles: Broken Console , Console, Console Fixer will dissapear and cant be crafted and used in creative mode.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
24 674
src/main/java/com/nonameaccount/theconsole/TheConsole.java
package com.nonameaccount.theconsole;

import com.nonameaccount.theconsole.network.OpenConsolePayload;
import com.nonameaccount.theconsole.network.RequestItemPayload;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.block.Block;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Set;

public class TheConsole implements ModInitializer {

    public static final String MOD_ID = "theconsole";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    private static final Set<Identifier> BREAK_ITEMS = Set.of(
            Identifier.of("minecraft", "barrier"),
            Identifier.of("minecraft", "command_block"),
            Identifier.of("minecraft", "repeating_command_block")
    );

    @Override
    public void onInitialize() {
        Blocks.initialize();

        PayloadTypeRegistry.playS2C().register(OpenConsolePayload.ID, OpenConsolePayload.CODEC);
        PayloadTypeRegistry.playC2S().register(RequestItemPayload.ID, RequestItemPayload.CODEC);

        ServerPlayNetworking.registerGlobalReceiver(RequestItemPayload.ID, (payload, context) -> {
            ServerPlayerEntity player = context.player();
            String raw = payload.itemId().trim().toLowerCase();
            if (raw.isEmpty()) return;

            if (!raw.contains(":")) {
                raw = "minecraft:" + raw;
            }

            String rawFinal = raw;
            Identifier id = Identifier.tryParse(rawFinal);
            if (id == null) {
                player.sendMessage(Text.literal("§c[Console] Invalid item ID: " + rawFinal), false);
                return;
            }

            if (!Registries.ITEM.containsId(id)) {
                player.sendMessage(Text.literal("§c[Console] Unknown item: " + rawFinal), false);
                return;
            }

            Item item = Registries.ITEM.get(id);
            if (item == Items.AIR) {
                player.sendMessage(Text.literal("§c[Console] Cannot request air."), false);
                return;
            }

            // Check if this is a forbidden item — break the console
            BlockPos consolePos = BlockPos.fromLong(payload.blockPosLong());
            ServerWorld world = player.getServerWorld();
            if (BREAK_ITEMS.contains(id)) {
                world.setBlockState(consolePos, Blocks.BROKEN_CONSOLE.getDefaultState());
                player.sendMessage(Text.literal("§4[Console] ERROR — SYSTEM FAILURE"), false);
                return;
            }

            clearConsoleItems(player);

            NbtCompound marker = new NbtCompound();
            marker.putBoolean("from_console", true);
            ItemStack stack = new ItemStack(item);
            stack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(marker));

            if (!player.getInventory().insertStack(stack)) {
                player.dropItem(stack, false);
            }

            player.sendMessage(Text.literal("§a[Console] Received: §f" + rawFinal), false);
        });
    }

    private static void clearConsoleItems(ServerPlayerEntity player) {
        PlayerInventory inv = player.getInventory();
        for (int i = 0; i < inv.size(); i++) {
            if (isConsoleItem(inv.getStack(i))) {
                inv.setStack(i, ItemStack.EMPTY);
            }
        }

        ServerWorld world = player.getServerWorld();
        Box scanBox = new Box(
                player.getX() - 512, player.getY() - 512, player.getZ() - 512,
                player.getX() + 512, player.getY() + 512, player.getZ() + 512
        );
        List<ItemEntity> dropped = world.getEntitiesByClass(ItemEntity.class, scanBox,
                e -> isConsoleItem(e.getStack()));
        for (ItemEntity ie : dropped) {
            ie.discard();
        }
    }

    public static boolean isConsoleItem(ItemStack stack) {
        if (stack.isEmpty()) return false;
        NbtComponent data = stack.get(DataComponentTypes.CUSTOM_DATA);
        if (data == null) return false;
        return data.copyNbt().getBoolean("from_console", false);
    }
}