Skip to content

Commit 23eb35f

Browse files
committed
加入物品栏槽位
1 parent 1dfe613 commit 23eb35f

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ when the void crashing.
88
when the reality breaks.
99
when ... you realize you can did it.
1010

11-
that time ...
12-
even the deepest shadow will fading away...
13-
14-
15-
16-
11+
that time ...
12+
even the deepest shadow will fading away...
1713

1814
Installation information
1915
=======

src/main/java/io/github/mxpea/fadingshadow/FadingShadow.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.mxpea.fadingshadow;
22

3+
import io.github.mxpea.fadingshadow.item.ModCreativeTab;
34
import io.github.mxpea.fadingshadow.item.ModItem;
45
import org.slf4j.Logger;
56

@@ -55,6 +56,7 @@ public class FadingShadow {
5556
public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder()
5657
.alwaysEdible().nutrition(1).saturationModifier(2f).build()));
5758

59+
/*
5860
// Creates a creative tab with the id "fadingshadow:example_tab" for the example item, that is placed after the combat tab
5961
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
6062
.title(Component.translatable("itemGroup.fadingshadow")) //The language key for the title of your CreativeModeTab
@@ -64,13 +66,16 @@ public class FadingShadow {
6466
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
6567
}).build());
6668
69+
*/
70+
6771
// The constructor for the mod class is the first code that is run when your mod is loaded.
6872
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
6973
public FadingShadow(IEventBus modEventBus, ModContainer modContainer) {
7074
// Register the commonSetup method for modloading
7175
modEventBus.addListener(this::commonSetup);
72-
76+
//初始化
7377
ModItem.register(modEventBus);
78+
ModCreativeTab.register(modEventBus);
7479

7580
// Register the Deferred Register to the mod event bus so blocks get registered
7681
BLOCKS.register(modEventBus);
@@ -106,7 +111,7 @@ private void commonSetup(FMLCommonSetupEvent event) {
106111
*/
107112
}
108113

109-
// Add the example block item to the building blocks tab
114+
// 创造模式物品栏分类
110115
private void addCreative(BuildCreativeModeTabContentsEvent event) {
111116
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS) {
112117
event.accept(ModItem.reality_fabric);
@@ -117,7 +122,7 @@ private void addCreative(BuildCreativeModeTabContentsEvent event) {
117122
// You can use SubscribeEvent and let the Event Bus discover methods to call
118123
@SubscribeEvent
119124
public void onServerStarting(ServerStartingEvent event) {
120-
// Do something when the server starts
125+
// 服务器启动时打印日志
121126
LOGGER.info("Fading,,,From where behind the reality..,");
122127
}
123128
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.github.mxpea.fadingshadow.item;
2+
3+
import io.github.mxpea.fadingshadow.FadingShadow;
4+
import net.minecraft.core.Registry;
5+
import net.minecraft.core.registries.Registries;
6+
import net.minecraft.network.chat.Component;
7+
import net.minecraft.resources.ResourceKey;
8+
import net.minecraft.world.item.CreativeModeTab;
9+
import net.minecraft.world.item.ItemStack;
10+
import net.neoforged.bus.api.IEventBus;
11+
import net.neoforged.neoforge.registries.DeferredRegister;
12+
13+
import java.util.function.Supplier;
14+
15+
public class ModCreativeTab {
16+
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS =
17+
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, FadingShadow.MODID);
18+
19+
public static final Supplier<CreativeModeTab> fading_shadow =
20+
CREATIVE_MODE_TABS.register("fs_tab", () -> CreativeModeTab.builder()
21+
.icon(() -> new ItemStack(ModItem.reality_fabric.get()))
22+
.title(Component.translatable("itemGroup.fs_tab"))
23+
.displayItems((parameters, output) -> {
24+
output.accept(ModItem.reality_fabric);
25+
output.accept(ModItem.apple_juice);
26+
}).build());
27+
28+
//初始化
29+
public static void register(IEventBus eventBus) {
30+
CREATIVE_MODE_TABS.register(eventBus);
31+
}
32+
}

src/main/resources/assets/fadingshadow/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"item.fadingshadow.reality_fabric": "Reality fabric",
33
"item.fadingshadow.apple_juice": "Apple juice",
4+
"itemGroup.fs_tab": "{Fading Shadow}",
45

56
"fadingshadow.configuration.title": "{Fading Shadow} Configs",
67
"fadingshadow.configuration.section.fadingshadow.common.toml": "{Fading Shadow} Configs",

src/main/resources/assets/fadingshadow/lang/zh_cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"item.fadingshadow.reality_fabric": "现实织料",
33
"item.fadingshadow.apple_juice": "苹果汁",
4+
"itemGroup.fs_tab": "{消逝之影}",
45

56
"fadingshadow.configuration.title": "{Fading Shadow} Configs",
67
"fadingshadow.configuration.section.fadingshadow.common.toml": "{Fading Shadow} Configs",

0 commit comments

Comments
 (0)