<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://mcbbs.wiki/index.php?action=history&amp;feed=atom&amp;title=%E7%94%A8%E6%88%B7%3AMashKJo%2F1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B%2F5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F</id>
	<title>用户:MashKJo/1.21.1模组开发教程/5.2.创造模式物品栏 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://mcbbs.wiki/index.php?action=history&amp;feed=atom&amp;title=%E7%94%A8%E6%88%B7%3AMashKJo%2F1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B%2F5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F"/>
	<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=%E7%94%A8%E6%88%B7:MashKJo/1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B/5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F&amp;action=history"/>
	<updated>2026-05-01T21:56:26Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.40.3</generator>
	<entry>
		<id>https://mcbbs.wiki/index.php?title=%E7%94%A8%E6%88%B7:MashKJo/1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B/5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F&amp;diff=55287&amp;oldid=prev</id>
		<title>MashKJo：​/* 修改已有的创造模式物品栏 */</title>
		<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=%E7%94%A8%E6%88%B7:MashKJo/1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B/5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F&amp;diff=55287&amp;oldid=prev"/>
		<updated>2025-09-06T17:15:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;修改已有的创造模式物品栏&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2025年9月7日 (日) 01:15的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot;&gt;第8行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第8行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  public static void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  public static void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     if(event.getTabKey() == CreativeModeTabs.INGREDIENTS) {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     if(event.getTabKey() == CreativeModeTabs.INGREDIENTS) {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         event.accept(&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;MyItemClass&lt;/del&gt;.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;MY_ITEM&lt;/del&gt;.get());&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         event.accept(&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ModItems&lt;/ins&gt;.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ONE_EXAMPLE_ITEM&lt;/ins&gt;.get());&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mcbbs_wiki:diff::1.12:old-55285:rev-55287 --&gt;
&lt;/table&gt;</summary>
		<author><name>MashKJo</name></author>
	</entry>
	<entry>
		<id>https://mcbbs.wiki/index.php?title=%E7%94%A8%E6%88%B7:MashKJo/1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B/5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F&amp;diff=55285&amp;oldid=prev</id>
		<title>MashKJo：​创建页面，内容为“显然，用/give命令获取我们注册进游戏的物品还是太麻烦了，我们还需要将新物品放进创造模式物品栏里。  == 修改已有的创造模式物品栏 == 如果你想将物品放入原版已有的创造模式物品栏，考虑监听事件BuildCreativeModeTabContentsEvent：   //应该被注册到Mod总线中。  @SubscribeEvent  public static void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {     if(eve…”</title>
		<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=%E7%94%A8%E6%88%B7:MashKJo/1.21.1%E6%A8%A1%E7%BB%84%E5%BC%80%E5%8F%91%E6%95%99%E7%A8%8B/5.2.%E5%88%9B%E9%80%A0%E6%A8%A1%E5%BC%8F%E7%89%A9%E5%93%81%E6%A0%8F&amp;diff=55285&amp;oldid=prev"/>
		<updated>2025-09-06T17:11:39Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“显然，用/give命令获取我们注册进游戏的物品还是太麻烦了，我们还需要将新物品放进创造模式物品栏里。  == 修改已有的创造模式物品栏 == 如果你想将物品放入原版已有的创造模式物品栏，考虑监听事件BuildCreativeModeTabContentsEvent：   //应该被注册到Mod总线中。  @SubscribeEvent  public static void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {     if(eve…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;显然，用/give命令获取我们注册进游戏的物品还是太麻烦了，我们还需要将新物品放进创造模式物品栏里。&lt;br /&gt;
&lt;br /&gt;
== 修改已有的创造模式物品栏 ==&lt;br /&gt;
如果你想将物品放入原版已有的创造模式物品栏，考虑监听事件BuildCreativeModeTabContentsEvent：&lt;br /&gt;
&lt;br /&gt;
 //应该被注册到Mod总线中。&lt;br /&gt;
 @SubscribeEvent&lt;br /&gt;
 public static void onBuildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {&lt;br /&gt;
    if(event.getTabKey() == CreativeModeTabs.INGREDIENTS) {&lt;br /&gt;
        event.accept(MyItemClass.MY_ITEM.get());&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== 自定义创造模式物品栏 ==&lt;br /&gt;
不过更通常的做法是将物品塞进自己自定义的创造模式物品栏中，创造模式物品栏（CreativeModeTab）和物品一样，是注册项，因此需要通过延迟注册机制注册进游戏：&lt;br /&gt;
&lt;br /&gt;
 public static final DeferredRegister&amp;lt;CreativeModeTab&amp;gt; CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, TutorialMod.MODID);&lt;br /&gt;
 &lt;br /&gt;
 public static final DeferredHolder&amp;lt;CreativeModeTab, CreativeModeTab&amp;gt; EXAMPLE_TAB = CREATIVE_MODE_TABS.register(&amp;quot;example_tab&amp;quot;, () -&amp;gt; CreativeModeTab.builder()&lt;br /&gt;
    .title(Component.translatable(&amp;quot;creative_mode_tab.tutorialmod.example_tab&amp;quot;))&lt;br /&gt;
    //指定创造模式物品栏的名称，为了使其能本地化，调用Component.translatable()。&lt;br /&gt;
    .icon(() -&amp;gt; new ItemStack(...))&lt;br /&gt;
    //指定创造模式物品栏的图标，接受一个Supplier&amp;lt;ItemStack&amp;gt;，...处填写一个物品对象。&lt;br /&gt;
    .displayItems((parameters, output) -&amp;gt; {&lt;br /&gt;
        output.accept(...);&lt;br /&gt;
        ...&lt;br /&gt;
    })&lt;br /&gt;
    //用于指定该创造模式物品栏中陈列哪些物品，#accept方法接受ItemLike和ItemStack。&lt;br /&gt;
    .build());&lt;br /&gt;
&lt;br /&gt;
记得把延迟注册器注册进Mod总线，并在语言文件中把创造模式物品栏的名称完成本地化。&lt;br /&gt;
&lt;br /&gt;
进入游戏，开启创造模式，物品栏调到第二页，即可看到你的创造模式物品栏了。&lt;/div&gt;</summary>
		<author><name>MashKJo</name></author>
	</entry>
</feed>