Example item added (Adamantite Ingot)

This commit is contained in:
Prabuddha Hans 2024-07-21 18:55:01 +01:00
parent f16b6596d6
commit 1598612b5d
5 changed files with 45 additions and 3 deletions

View file

@ -0,0 +1,22 @@
package com.example;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class AdamantiteIngot extends Item{
public AdamantiteIngot(Item.Settings settings) {
super(settings);
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
user.playSound(SoundEvents.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.0f);
return TypedActionResult.success(user.getStackInHand(hand));
}
}

View file

@ -2,6 +2,15 @@ package com.example;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -10,13 +19,15 @@ public class ExampleMod implements ModInitializer {
// It is considered best practice to use your mod id as the logger's name. // It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors. // That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("examplemod"); public static final Logger LOGGER = LoggerFactory.getLogger("examplemod");
public static final AdamantiteIngot ADAMANTITE_INGOT = new AdamantiteIngot(new Item.Settings());
@Override @Override
public void onInitialize() { public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state. // This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized. // However, some things (like resources) may still be uninitialized.
// Proceed with mild caution. // Proceed with mild caution.
Registry.register(Registries.ITEM, new Identifier("examplemod", "adamantite_ingot"), ADAMANTITE_INGOT);
LOGGER.info("Hello Fabric world!"); ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(content -> {
content.addAfter(Items.DIAMOND, ADAMANTITE_INGOT);
});
} }
} }

View file

@ -0,0 +1,3 @@
{
"item.examplemod.adamantite_ingot": "Adamantite Ingot"
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "examplemod:item/adamantite_ingot"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B