Darikated

Minecraft Fabric Mod Development Prompt: Instant Ignited TNT

Project Overview

Create a fully functional Minecraft Java Edition mod that automatically ignites TNT immediately when the player places a TNT block.

Target Environment

  • Minecraft Java Edition: 1.21.11
  • Mod loader: Fabric
  • Fabric Loader: 0.19.3
  • Language: Java
  • Build system: Gradle with Fabric Loom
  • Output: A ready-to-use, compiled ".jar" mod file compatible with the specified environment.
  1. Core Functionality — Instant TNT Conversion

When a player places a TNT block, the mod must immediately perform the following actions:

  1. Detect the successful placement of a TNT block by a player.
  2. Determine the exact block position where the TNT was placed.
  3. Remove the newly placed TNT block from the world immediately.
  4. Spawn a primed TNT entity ("TntEntity") at the appropriate position corresponding to the removed TNT block.
  5. Ensure the spawned entity is already ignited and begins its normal fuse countdown immediately.
  6. The conversion must happen automatically without requiring flint and steel, fire charges, redstone, fire, commands, or any other ignition method.

Important: Do not leave the TNT block in the world for an extra tick before converting it. The block should be removed and replaced with the primed TNT entity as part of the placement process, as immediately as the Minecraft and Fabric event lifecycle safely permits.

  1. Authentic TNT Ignition Physics — Essential

The spawned TNT must behave exactly like naturally primed TNT in vanilla Minecraft.

Do NOT simply spawn a TNT entity with zero velocity or make it fall directly downward.

When TNT is normally ignited in vanilla Minecraft, it receives an initial upward and horizontal velocity, producing a small hop before it falls under gravity.

Reproduce this behavior by using Minecraft's native TNT priming and velocity initialization logic wherever possible.

Requirements:

  • The TNT should perform the characteristic small upward hop immediately after placement.
  • Its initial velocity should resemble vanilla TNT primed by flint and steel.
  • It should have the natural horizontal movement associated with vanilla TNT priming.
  • Gravity, air resistance, collision, bouncing behavior, and movement must remain vanilla.
  • Do not implement a custom animation that merely looks like a hop while the entity remains stationary.
  • Do not manually apply a second upward impulse if the native priming method already applies one.

Preferred implementation: Reuse the same vanilla entity creation and priming logic that is executed when a TNT block is normally ignited. Investigate the target version's "TntBlock" implementation and use the appropriate native method, such as its priming/entity-creation logic, rather than duplicating the physics unnecessarily.

  1. Vanilla Fuse and Explosion Behavior

The TNT must retain normal vanilla behavior after being spawned.

  • Use the standard vanilla primed TNT entity.
  • Preserve the normal fuse duration, approximately 80 game ticks under default conditions.
  • Preserve vanilla explosion power and damage behavior.
  • Preserve normal collision and entity interaction.
  • Ensure the entity is properly registered with the world and synchronized to clients.
  • Do not create a custom TNT entity unless absolutely necessary.

The TNT must be a real primed TNT entity, not a visual substitute or particle effect.

  1. Placement Rules and Edge Cases

The mod should:

  • Work whenever a player successfully places a TNT block.
  • Support survival and creative modes.
  • Work with normal TNT placement on the ground and on other blocks.
  • Avoid converting TNT blocks that already existed in the world before the player placed another TNT block.
  • Avoid accidentally spawning two TNT entities from a single placement.
  • Avoid infinite event recursion or repeatedly processing the same placement.
  • Respect server-side execution and avoid spawning duplicate entities in multiplayer.
  • Ensure the block is removed safely and the entity is spawned exactly once.

Perform the authoritative block removal and entity spawning on the logical server. Client-side code may handle visual synchronization but must not independently create another authoritative TNT entity.

If a player cannot successfully place TNT, nothing should happen.

  1. Technical Implementation Requirements

Before writing code:

  1. Verify the Minecraft 1.21.11 mappings and available Fabric API events.
  2. Inspect the actual target version's TNT block implementation.
  3. Identify the correct placement hook or mixin for detecting successful TNT placement.
  4. Confirm the correct constructor, factory, or native priming method for creating a primed TNT entity.
  5. Confirm how the native TNT priming logic initializes its velocity and fuse.

Choose the least invasive reliable implementation. If an appropriate Fabric API placement event cannot provide the required timing or behavior, use a narrowly scoped Mixin into the relevant vanilla TNT placement logic.

Do not rely on outdated method names or code copied from older Minecraft versions without verifying compatibility with 1.21.11.

  1. Performance and Compatibility
  • Keep the mod lightweight.
  • Avoid per-tick world scanning.
  • Do not add unnecessary configuration screens, keybinds, commands, particles, or custom rendering.
  • Do not require client-side entity duplication.
  • Ensure the mod can operate correctly in single-player.
  • If multiplayer support is implemented, ensure the server controls TNT creation and explosion behavior.
  • Avoid unnecessary dependencies beyond the required Fabric environment.
  1. Build and Deliverables

Deliver the following:

  1. Complete Java source code.
  2. Correct "fabric.mod.json".
  3. Correct Gradle build files and dependency declarations.
  4. Any required Mixin configuration.
  5. A successfully compiled mod ".jar" targeting Minecraft 1.21.11 and compatible with Fabric Loader 0.19.3.
  6. The source project in a ZIP file.
  7. Brief installation instructions.

Do not deliver only pseudocode, a tutorial, or example snippets. Actually compile the mod and verify that the resulting JAR has the correct metadata and required classes.

  1. Testing Checklist

Test the compiled mod in the specified Minecraft and Fabric environment.

  • [ ] Place TNT on a solid block: the TNT block disappears immediately.
  • [ ] A single primed TNT entity appears at the placement location.
  • [ ] The TNT performs the characteristic vanilla ignition hop.
  • [ ] The TNT moves naturally under vanilla physics.
  • [ ] The fuse counts down normally and the TNT explodes normally.
  • [ ] Repeated TNT placement never creates duplicate entities.
  • [ ] Existing TNT blocks are unaffected.
  • [ ] The mod does not crash during startup or world loading.
  • [ ] No missing mappings, invalid mixins, or incompatible method signatures occur.

Final priority: Authentic vanilla TNT behavior is more important than a custom implementation. When the player places TNT, it must effectively behave as if that TNT block had been immediately primed using vanilla flint-and-steel ignition logic, including the initial hop, normal fuse, and normal explosion.

Kodari AI
KodariOct 10 at 2:34 am 2
InstantIgnitedTNT
Automatically ignites TNT blocks the moment a player places them. Uses a Fabric Mixin to intercept TNT block placement, immediately removing the placed block and spawning a primed TNT entity with authentic vanilla ignition physics, including the characteristic upward hop. Preserves normal fuse duration, explosion power, and entity behavior. Works in survival and creative modes, server-authoritative, with no duplicate entity spawning or performance overhead.
  1. Verify the 1.21.11 TNT placement and priming hooks.

  2. Create a minimal Fabric mod with a server-side mixin that reuses vanilla TNT priming behavior.

  3. Add Gradle, Fabric metadata, and mixin configuration; the project can then be compiled and downloaded in Kodari.

  1. Added the Fabric 1.21.11 project and a mixin that detects successful player placement, primes TNT server-side through vanilla TntBlock.primeTnt, then removes the block using vanilla’s update flags. This preserves the native fuse, hop, and TNT physics.

  2. The source files are in the project workspace. I did not compile or run the in-game checklist here, and no separate source ZIP or JAR was generated.

To build and download the JAR in Kodari: click Compile in the desktop top bar (or ⋮ → Compile Project on phone), click Compile, then Download after it succeeds. Install it with Fabric Loader 0.19.3 and Fabric API for Minecraft 1.21.11.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 129
src/main/java/com/kodari/instantignitedtnt/mixin/BlockMixin.java
package com.kodari.instantignitedtnt.mixin;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.BlockState;
import net.minecraft.block.TntBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Block.class)
public abstract class BlockMixin {
    @Inject(method = "onPlaced", at = @At("HEAD"))
    private void instant_ignited_tnt$primeOnPlayerPlacement(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack, CallbackInfo ci) {
        if (world.isClient() || !(placer instanceof PlayerEntity) || !state.isOf(Blocks.TNT) || !world.getBlockState(pos).isOf(Blocks.TNT)) {
            return;
        }

        if (TntBlock.primeTnt(world, pos)) {
            world.setBlockState(pos, Blocks.AIR.getDefaultState(), Block.NOTIFY_ALL_AND_REDRAW);
        }
    }
}