Роман Иванов
📎 1 file 1,153 chars
📄
pasted-code-1792758250928.txt
txt 18 lines
▶
Create a Minecraft Fabric 1.20.4 mod named "Voxel Destruction". I want a mix of Teardown destruction and Lay of the Land atmosphere.

Please generate the following content:

1. Custom Block: "Fragile Concrete" (ID: fragile_concrete). 
- It should look like a heavy concrete block.
- Special mechanic: It should NOT break in one hit. It needs to have 4 destruction stages. Every time a player hits it, it changes its texture to show more cracks (use block states for the 4 stages). Only after the 4th hit, it breaks completely and drops 4 smaller "rubble" items.

2. Custom Item: "Sledgehammer" (ID: sledgehammer).
- A heavy tool that deals high damage to the "Fragile Concrete" block (instantly advances one destruction stage).
- When hitting normal blocks, it breaks them normally but slower than a pickaxe.

3. Custom Item: "Rubble" (ID: rubble).
- A small piece of debris that drops from the destroyed concrete.
- Player can use it to craft new concrete blocks.

4. Environment/Atmosphere:
- Add a custom fog effect or darken the ambient light slightly to give the world a moody, atmospheric feeling (like in "Lay of the Land" game).
Kodari AI
KodariOct 23 at 12:42 pm 17
VoxelDestruction
A Minecraft Fabric 1.20.4 mod blending Teardown-style destruction with Lay of the Land atmosphere. Adds Fragile Concrete blocks with 4 destruction stages that crack progressively when hit, requiring multiple hits to break and dropping Rubble items. Includes a Sledgehammer tool that advances destruction stages instantly on concrete and breaks normal blocks slower than a pickaxe. Rubble can be crafted back into concrete blocks. Also introduces a custom fog effect and darkened ambient lighting to create a moody, atmospheric world environment.
  1. Register the block, items, recipes, and survival drops.

  2. Implement four server-authoritative crack stages and the sledgehammer.

  3. Add a subtle moody fog effect, then supply the required assets and models.

Created the Fabric 1.20.4 Voxel Destruction project with four server-handled damage stages, a durable, iron-repairable sledgehammer, rubble drops, crafting recipes, and darker fog.

Survival routes: craft 4 rubble from cobblestone and gravel; craft Fragile Concrete from 4 rubble; craft the sledgehammer from 2 iron ingots and 2 sticks. Breaking Fragile Concrete also drops 4 rubble.

Texture note: The intact and first-crack textures were generated. Stages 2 and 3 currently reuse the first-crack texture with different rotations, rather than having unique, progressively cracked artwork.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
24 383
src/main/java/net/kodari/voxeldestruction/VoxelDestruction.java
package net.kodari.voxeldestruction;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.MapColor;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;

public class VoxelDestruction implements ModInitializer {
    public static final String MOD_ID = "voxeldestruction";

    public static final FragileConcreteBlock FRAGILE_CONCRETE = Registry.register(
            Registries.BLOCK,
            new Identifier(MOD_ID, "fragile_concrete"),
            new FragileConcreteBlock(AbstractBlock.Settings.create()
                    .mapColor(MapColor.STONE_GRAY)
                    .strength(3.5F, 6.0F)
                    .requiresTool()
                    .sounds(BlockSoundGroup.STONE))
    );

    public static final BlockItem FRAGILE_CONCRETE_ITEM = Registry.register(
            Registries.ITEM,
            new Identifier(MOD_ID, "fragile_concrete"),
            new BlockItem(FRAGILE_CONCRETE, new Item.Settings())
    );

    public static final SledgehammerItem SLEDGEHAMMER = Registry.register(
            Registries.ITEM,
            new Identifier(MOD_ID, "sledgehammer"),
            new SledgehammerItem()
    );

    public static final Item RUBBLE = Registry.register(
            Registries.ITEM,
            new Identifier(MOD_ID, "rubble"),
            new Item(new Item.Settings())
    );

    @Override
    public void onInitialize() {
        ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(
                RegistryKeys.ITEM_GROUP,
                new Identifier("minecraft", "building_blocks")
        )).register(entries -> entries.add(FRAGILE_CONCRETE_ITEM));

        ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(
                RegistryKeys.ITEM_GROUP,
                new Identifier("minecraft", "tools_and_utilities")
        )).register(entries -> entries.add(SLEDGEHAMMER));

        ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(
                RegistryKeys.ITEM_GROUP,
                new Identifier("minecraft", "ingredients")
        )).register(entries -> entries.add(RUBBLE));

        AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
            if (!world.getBlockState(pos).isOf(FRAGILE_CONCRETE)) {
                return ActionResult.PASS;
            }

            if (!world.isClient()) {
                FRAGILE_CONCRETE.advanceStage(world, pos, player, hand);
            }

            return ActionResult.SUCCESS;
        });
    }
}