#[1.21.6] Following Tutorial for 1.21.4, setting up basic items, blocks, recipes, loot_tables, etc

1 messages · Page 1 of 1 (latest)

neon laurel
#

Hey, I'm new to fabric modding and I went over the documentation but it's a little bit unclear on the details around adding the block as an item properly. I was about to add it as one, but it's not rendering in hand or inventory properly nor it is using the translation tooltip I expected.

Here's my source. I'm sure I'm making a very simple mistake.

topaz wyvern
#

Probably because you forgot to create the model description file for the block

neon laurel
#

I followed the guide for making items, and that worked just fine, no notes.

#

but with blocks, it wasn't wholly clear.

topaz wyvern
#

There is no official documentation for 1.21.6 yet. But starting from version 1.21.4, the process of creating items or block items requires the creation of corresponding model description files;

You'd better create the "assets\strawberry\items" folder at first and add a file named pink_stone.json in it. The content of the file is as follows:

{
    "model": {
        "type": "minecraft:model",
        "model": "strawberry:block/pink_stone"
    }
}

The model description should be stored in assets/{mod-id}/items
and the model is stored in assets/{mod-id}/models
I'm not sure if it works in version 1.21.6, but you can give it a try.

limpid compass
#

it has not changed, the 1.21.4 docs should be still valid

neon laurel
#

Ok, I see where my understanding was deficient here

#

Trying that rn.

neon laurel
#

ok, it worked! with one little exception. the tutorial documentation suggested this for en_us.json:

{
  "block.strawberry.pink_stone": "Pink Stone"
}

but ingame, the item tooltip still says it should be item.strawberry.pink_stone

#

so should I just go with what I know works and just include a lang entry for item.strawberry.pink_stone?

#

or is there a reason to specify block.strawberry.pink_stone and I should revisit a different resource to configure it properly?

ember magnet
neon laurel
# ember magnet on the Item.Settings there’s a method you can call to use the block. prefix inst...

what call is that? here's what I have in ModBlocks

    public static void initialize() {
        ItemGroupEvents.modifyEntriesEvent(net.minecraft.item.ItemGroups.BUILDING_BLOCKS).register((itemGroup) -> {
            itemGroup.add(ModBlocks.PINK_STONE.asItem());
        });
    }

    public static final Block PINK_STONE = register(
            "pink_stone",
            Block::new,
            AbstractBlock.Settings.create()
                    .strength(1.5f, 6.0f)
                    .sounds(BlockSoundGroup.STONE),
            true
    );
ember magnet
#

itll be wherever you register the blockitem

neon laurel
#

ok so I'm still using the code verbatim that was in the documentation example.

#
    private static Block register(String name, Function<AbstractBlock.Settings, Block> blockFactory, AbstractBlock.Settings settings, boolean shouldRegisterItem) {
        // Create a registry key for the block
        RegistryKey<Block> blockKey = keyOfBlock(name);
        // Create the block instance
        Block block = blockFactory.apply(settings.registryKey(blockKey));

        // Sometimes, you may not want to register an item for the block.
        // Eg: if it's a technical block like `minecraft:moving_piston` or `minecraft:end_gateway`
        if (shouldRegisterItem) {
            // Items need to be registered with a different type of registry key, but the ID
            // can be the same.
            RegistryKey<Item> itemKey = keyOfItem(name);

            BlockItem blockItem = new BlockItem(block, new Item.Settings().registryKey(itemKey));
            Registry.register(Registries.ITEM, itemKey, blockItem);
        }

        return Registry.register(Registries.BLOCK, blockKey, block);
    }

    private static RegistryKey<Block> keyOfBlock(String name) {
        return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(Strawberry.MOD_ID, name));
    }

    private static RegistryKey<Item> keyOfItem(String name) {
        return RegistryKey.of(RegistryKeys.ITEM, Identifier.of(Strawberry.MOD_ID, name));
    }
#

I'm still trying to understand how it works the way that it works, but maybe you can clue me in on the right method and I'll keep a note of it

#

keyOfBlock I assume?

ember magnet
#

here new Item.Settings().registryKey(itemKey), i cant remember what the method is off the top of my head, but i believe its something like blockprefixedtranslation or something

#

ah Item.Settings#useBlockPrefixedTranslationKey

neon laurel
#

I'm looking in the documentation, where did you find useBlockPrefixedTranslationKey?

ember magnet
#

which documentation? it was added in 1.21.5 so it’s possible the docs are outdated

neon laurel
#

I found it eventually

ember magnet
#

wait no 1.21.2

neon laurel
#

which is mostly just a few very anemic tutorials I think

ember magnet
#

huh, I’d expect that to have it considering it’s for 1.21.4

neon laurel
#

I'm sure I'm going to run into a lot of small irregularities like this, but I'll work it out.

#

what I really want to know is whether it's preferable to use the Block prefixed key

#

and WHY it's preferable or not

ember magnet
#

yes, because the block prefix appears elsewhere such as the flat world creation screen (and probably other places too) regardless of which prefix the item itself uses. Also, mojang do it

neon laurel
#

good enough for me

neon laurel
#

just fyi, the right usage seems to be

            BlockItem blockItem = new BlockItem(block, new Item.Settings()
                    .registryKey(itemKey)
                    .useBlockPrefixedTranslationKey());
neon laurel
#

so I've migrated onto a new problem, trying to add more functionality to these new blocks. I'm just replicating existing blocks as a pink variant while I work out how the mod is put together, so it should be pretty simple to see what I'm trying to achieve.

#

here's my directory tree so far, I'm only adding pink_stone and pink_cobblestone at the moment. I got these blocks working in creative, but now I'm trying to set up the tool harvesting, loot_tables, and a single crafting recipe (smelting pink stone into pink cobblestone)

#

here's the details on the blocks I've made

    public static final Block PINK_STONE = register(
            "pink_stone",
            Block::new,
            AbstractBlock.Settings.create()
                    .mapColor(MapColor.PINK)
                    .requiresTool()
                    .strength(1.5f, 6.0f)
                    .sounds(BlockSoundGroup.STONE),
            true
    );

    public static final Block PINK_COBBLESTONE = register(
            "pink_cobblestone",
            Block::new,
            AbstractBlock.Settings.create()
                    .mapColor(MapColor.PINK)
                    .requiresTool()
                    .strength(2.0f, 6.0f)
                    .sounds(BlockSoundGroup.STONE),
            true
    );
#

pickaxe.json

{
  "replace": false,
  "values": [
    "strawberry:pink_stone",
    "strawberry:pink_cobblestone"
  ]
}
#

pink_stone.json

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "strawberry:pink_cobblestone"
        }
      ],
      "conditions": [
        { "condition": "minecraft:survives_explosion" },
        {
          "condition": "minecraft:match_tool",
          "predicate": {
            "predicate_type": "minecraft:tool",
            "tag": "minecraft:mineable/pickaxe"
          }
        }
      ]
    }
  ]
}
#

pink_stone_from_smelting.json

{
  "type": "minecraft:smelting",
  "ingredient": {
    "item": "strawberry:pink_cobblestone"
  },
  "result": "strawberry:pink_stone",
  "experience": 0.1,
  "cookingtime": 200
}
#

I also have an advancement json for unlcoking it in the recipe book but I don't care about that right now.

#

this was suggested by the docs to be enough, but it's not working ingame. have I missed something?

#

[1.21.6] Following Tutorial for 1.21.4, setting up basic items, blocks, recipes, loot_tables, etc

topaz wyvern
#

Try to rename the pink_stone_from_smelting.json to pink_stone.json to see if you can smelt cobblestone into stone

neon laurel
#

will do. got a clue about why tool harvesting isn't working?

topaz wyvern
#

What tool would you like to use to break pink stone?

neon laurel
#

just any pickaxe will do

#

for the purposes of this mod, pink stone/cobble is equivalent to the normal kind, it's just got a different texture and would have unique recipes for other pink variant blocks and items

#

I'm just using this idea to pick up on the basics for modding

neon laurel
#

I don't get it, it doesn't seem to be loading any of my datapack json files

#

I was thinking directory issue? But I've checked it over and over

topaz wyvern
#

I think that is a really small mistake. Change this to block insteaf of blocks.

neon laurel
#

damn, there it is!

#

that's one issue

#

the attention to detail is excruciating sometimes, isn't it? that fixed at least the pickaxes not working.

topaz wyvern
neon laurel
#

addressed for now and noted

#
Minecraft Wiki

A data pack is a collection of data used to configure a number of features of Minecraft. A data pack is either a folder or a .zip file containing a pack.mcmeta file. Data packs are used to define among others advancements, dimensions, enchantments, loot tables, recipes, structures, and biomes (see § Contents for a full list). The definitions of...

#

it looks like loot_table should not be plural either

#

nor recipe

#

it's the same problem everywhere

topaz wyvern
neon laurel
#

checking now. what's this element found in the loot table for minecraft:stone?

"random_sequence": "minecraft:blocks/stone"

topaz wyvern
#
Minecraft Wiki

Loot tables are technical JSON files that are used to dictate what items should generate in various situations, such as what items should be in naturally generated containers, what items should drop when breaking a block or killing a mob, what items can be fished, and more. It does not affect dropped experience, or dropped non-item entities such...

neon laurel
#

I saw that, but it's still a bit unclear to me. what is "minecraft:blocks/stone" a resource location for?

#

I think this is what seeds the randomness of some loot tables?

#

if "minecraft:blocks/stone" is the name of a random sequence stored somewhere, then where is this sequence? should I care about this at all?

#

ok

#

ok, GREAT

#

I still have questions about certain details like the above, but looking at minecraft's data I am on much firmer footing I think

topaz wyvern
neon laurel
#

yeah, I'm sure it will matter later but at the moment, it's out of scope

#

after fiddling with this some more the next thing I might look at are generators