添加方块

image-20231028204614315

添加方块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package net.tutorialmod.item;

import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.Item;
import net.tutorialmod.TutorialMod;

public class ModItem {


public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(TutorialMod.MOD_ID, Registries.ITEM);
public static final RegistrySupplier<Item> EXAMPLE_ITEM = ITEMS.register("zircon", () ->
new Item(new Item.Properties().arch$tab(ModCreativeTab.EXAMPLE_TAB)));


public static void register(){
ITEMS.register();
}

}

添加创造物品栏

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package net.tutorialmod.item;

import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.tutorialmod.TutorialMod;

public class ModCreativeTab {
public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(TutorialMod.MOD_ID, Registries.CREATIVE_MODE_TAB);


public static final RegistrySupplier<CreativeModeTab> EXAMPLE_TAB = TABS.register("example_tab", () ->
CreativeTabRegistry.create(Component.translatable("itemGroup." + TutorialMod.MOD_ID + ".example_tab"),
() -> new ItemStack(ModItem.EXAMPLE_ITEM.get())));

public static void register(){
TABS.register();
}


}

创建语言文件

1
2
3
4
5

{
"item.tutorialmod.zircon": "Zircon",
"itemGroup.tutorialmod.example_tab": "TutoriablTab"
}

创建models-item

1
2
3
4
5
6
7

{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "tutorialmod:item/zircon"
}
}

创建贴图

image-20231028204651340

进入游戏测试

image-20231028204958179