#item wont show up in game

14 messages · Page 1 of 1 (latest)

marble pike
#

This is the code

package sidjack.sidjackstestmod.registry;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups; // Correct import for ItemGroups
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ItemRegistry implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(ItemRegistry.class);
public static final Item SIDJACK_INGOT = registerItem("sidjack_ingot", new Item(new Item.Settings()));

private static Item registerItem(String id, Item item) {
    LOGGER.info("Registering item: {}", id);
    return Registry.register(Registries.ITEM, new Identifier.Serializer().toString(), item);
}

@Override
public void onInitialize() {
    LOGGER.info("Initializing ItemRegistry");
    ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS)
            .register(itemGroup -> {
                LOGGER.info("Adding item to ItemGroup.BUILDING_BLOCKS");
                itemGroup.add(SIDJACK_INGOT);
            });
}

}

hot crater
#

new Identifier.Serializer().toString()

#

thats not how you construct an identifier

marble pike
#

how do i fix it

hot crater
#

use Identifier.of(namespace, path) where namespace is your mod id and path (in this case) is your item id

marble pike
#

ive messed around with the code again and it still doesnt show up

#

package sidjack.sidjackstestmod.registry;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ItemRegistry implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(ItemRegistry.class);
public static final Item SIDJACK_INGOT = registerItem("sidjack_ingot", new Item(new Item.Settings()));

private static Item registerItem(String sidjack_ingot, Item item) {
    LOGGER.info("Registering item: {}", sidjack_ingot);
    return Registry.register(Registries.ITEM, Identifier.of("sidjackstestmod", sidjack_ingot), item);
}

@Override
public void onInitialize() {
    LOGGER.info("Initializing ItemRegistry");
    ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS)
            .register(itemGroup -> {
                LOGGER.info("Adding item to ItemGroups.BUILDING_BLOCKS");
                itemGroup.add(ItemRegistry.SIDJACK_INGOT);
            });
}

}

rotund patio
#

You are using sidjack_ingot as your path in the Identifier but it has to be a String (and you don't have a variable called "sidjack_ingot"

west ravine
#

What do you mean with "doesn't show up"? Can you /give yourself the item? Does it not have a texture?

rotund patio
#

You might want a better name than that to avoid confusion

vivid widget
#

and please

#

!!code

pine roostBOT
#

You can use codeblocks in discord as shown below:
```java
code
```

You can also specify the syntax highlighting to use by specifying the language after the last backtick (`) on the top.