Shawn Turner

can you make a 26.2 fabric mod that right clicks an omonious vault when a heavy core will come out

Kodari AI
KodariNov 7 at 9:14 am 2
OminousVaultHeavyCore
A Minecraft Fabric 1.26.2 mod that detects when a player right-clicks an Ominous Vault and spawns a Heavy Core as a reward. The mod listens for block interaction events, verifies the target block is an Ominous Vault, and then spawns a Heavy Core entity at the vault's location with a brief visual effect. The Heavy Core spawns with proper physics and can be collected by the player. The mod includes configuration options for spawn delay, core count, and whether to consume the vault's charge. Compatible with vanilla Minecraft mechanics and designed for seamless integration into existing worlds.
  1. Check whether 26.2 exposes a reliable pre-open signal for a Heavy Core in an ominous vault.

  2. Build the smallest survival-safe Fabric mod the game’s actual vault flow supports.The server does not reveal the actual reward before interaction. I’m implementing the practical approximation: right-click once when an ominous vault’s visible preview shows a Heavy Core; that preview is not a guarantee.

Created the client-side Fabric 26.2 mod. While you’re looking at a vault, it uses an ominous trial key from either hand once if the vault’s visible preview shows a Heavy Core.

Important: the preview is not the vault’s guaranteed reward—vanilla only generates the actual loot on interaction, so the mod can’t know in advance whether a Heavy Core will really come out. No new items or other survival content were added.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 121
src/client/java/com/kodari/heavycoreautovault/HeavyCoreAutoVaultClient.java
package com.kodari.heavycoreautovault;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.entity.vault.VaultBlockEntity;
import net.minecraft.world.phys.BlockHitResult;

public class HeavyCoreAutoVaultClient implements ClientModInitializer {
	private BlockPos lastAttemptedVault;

	@Override
	public void onInitializeClient() {
		ClientTickEvents.END_CLIENT_TICK.register(this::tryUseVault);
	}

	private void tryUseVault(Minecraft client) {
		if (client.player == null || client.level == null || client.gameMode == null
				|| !(client.hitResult instanceof BlockHitResult hit)) {
			lastAttemptedVault = null;
			return;
		}

		if (!(client.level.getBlockEntity(hit.getBlockPos()) instanceof VaultBlockEntity vault)
				|| vault.getSharedData().getDisplayItem().getItem() != Items.HEAVY_CORE) {
			lastAttemptedVault = null;
			return;
		}

		InteractionHand hand;
		if (client.player.getMainHandItem().getItem() == Items.OMINOUS_TRIAL_KEY) {
			hand = InteractionHand.MAIN_HAND;
		} else if (client.player.getOffhandItem().getItem() == Items.OMINOUS_TRIAL_KEY) {
			hand = InteractionHand.OFF_HAND;
		} else {
			lastAttemptedVault = null;
			return;
		}

		BlockPos pos = hit.getBlockPos();
		if (pos.equals(lastAttemptedVault)) {
			return;
		}

		lastAttemptedVault = pos;
		client.gameMode.useItemOn(client.player, hand, hit);
	}
}