<?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=FancyMenu_Wiki%2F%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA</id>
	<title>FancyMenu Wiki/自定义按钮行为 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://mcbbs.wiki/index.php?action=history&amp;feed=atom&amp;title=FancyMenu_Wiki%2F%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA"/>
	<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;action=history"/>
	<updated>2026-05-04T21:09:28Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.40.3</generator>
	<entry>
		<id>https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;diff=39977&amp;oldid=prev</id>
		<title>Litwak913：​// Edit via Wikiplus</title>
		<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;diff=39977&amp;oldid=prev"/>
		<updated>2022-11-22T07:34:17Z</updated>

		<summary type="html">&lt;p&gt;// Edit via Wikiplus&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;2022年11月22日 (二) 15:34的版本&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-l241&quot;&gt;第241行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第241行：&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;br/&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;br/&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 colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[分类:FancyMenu]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mcbbs_wiki:diff::1.12:old-39974:rev-39977 --&gt;
&lt;/table&gt;</summary>
		<author><name>Litwak913</name></author>
	</entry>
	<entry>
		<id>https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;diff=39974&amp;oldid=prev</id>
		<title>Litwak913：​/* 添加新的按钮行为 */ // Edit via Wikiplus</title>
		<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;diff=39974&amp;oldid=prev"/>
		<updated>2022-11-22T07:14:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;添加新的按钮行为：​&lt;/span&gt; // Edit via Wikiplus&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;2022年11月22日 (二) 15:14的版本&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;每一个自定义按钮行为都应被封装到 &amp;lt;code&amp;gt;ButtonActionContainer&amp;lt;/code&amp;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;每一个自定义按钮行为都应被封装到 &amp;lt;code&amp;gt;ButtonActionContainer&amp;lt;/code&amp;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;br/&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;br/&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;这个 container 需要在模组中初始化注册到 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ButtonActionRegistry。&lt;/del&gt;&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;这个 container 需要在模组中初始化注册到 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;ButtonActionRegistry&amp;lt;/code&amp;gt;。&lt;/ins&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;=== 创建 ButtonActionContainer ===&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;=== 创建 ButtonActionContainer ===&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;给你的按钮行为创建新的 ButtonActionContainer 子类，并为其命名。&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;给你的按钮行为创建新的 ButtonActionContainer 子类，并为其命名。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mcbbs_wiki:diff::1.12:old-39973:rev-39974 --&gt;
&lt;/table&gt;</summary>
		<author><name>Litwak913</name></author>
	</entry>
	<entry>
		<id>https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;diff=39973&amp;oldid=prev</id>
		<title>Litwak913：​创建页面，内容为“== 关于 == 你可以使用FancyMenu API来写一个自定义按钮行为的拓展模组。你也可以将其用于自定义按钮元素，也可以在通过点击按钮执行你写的自定义按钮行为。  == 准备开发环境 == 请参阅 准备工作区。  == 添加新的按钮行为 == 每一个自定义按钮行为都应被封装到 &lt;code&gt;ButtonActionContainer&lt;/code&gt; (按钮行为容器)。  这个 container 需要…”</title>
		<link rel="alternate" type="text/html" href="https://mcbbs.wiki/index.php?title=FancyMenu_Wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%89%E9%92%AE%E8%A1%8C%E4%B8%BA&amp;diff=39973&amp;oldid=prev"/>
		<updated>2022-11-22T07:14:14Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“== 关于 == 你可以使用FancyMenu API来写一个自定义按钮行为的拓展模组。你也可以将其用于自定义按钮元素，也可以在通过点击按钮执行你写的自定义按钮行为。  == 准备开发环境 == 请参阅 &lt;a href=&quot;/wiki/FancyMenu_Wiki/%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C%E5%8C%BA&quot; title=&quot;FancyMenu Wiki/准备工作区&quot;&gt;准备工作区&lt;/a&gt;。  == 添加新的按钮行为 == 每一个自定义按钮行为都应被封装到 &amp;lt;code&amp;gt;ButtonActionContainer&amp;lt;/code&amp;gt; (按钮行为容器)。  这个 container 需要…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== 关于 ==&lt;br /&gt;
你可以使用FancyMenu API来写一个自定义按钮行为的拓展模组。你也可以将其用于自定义按钮元素，也可以在通过点击按钮执行你写的自定义按钮行为。&lt;br /&gt;
&lt;br /&gt;
== 准备开发环境 ==&lt;br /&gt;
请参阅 [[FancyMenu_Wiki/准备工作区|准备工作区]]。&lt;br /&gt;
&lt;br /&gt;
== 添加新的按钮行为 ==&lt;br /&gt;
每一个自定义按钮行为都应被封装到 &amp;lt;code&amp;gt;ButtonActionContainer&amp;lt;/code&amp;gt; (按钮行为容器)。&lt;br /&gt;
&lt;br /&gt;
这个 container 需要在模组中初始化注册到 ButtonActionRegistry。&lt;br /&gt;
=== 创建 ButtonActionContainer ===&lt;br /&gt;
给你的按钮行为创建新的 ButtonActionContainer 子类，并为其命名。&lt;br /&gt;
&lt;br /&gt;
在这个样例中，我会给我的演示按钮行为类命名为 ExampleButtonActionContainerWithValue。&lt;br /&gt;
&lt;br /&gt;
在这个类中有一些重要的特殊东西需要解释一下。&lt;br /&gt;
==== 构造方法(Constructor) ====&lt;br /&gt;
构造方法(Constructor)用于为你的按钮行为设置标识符。&lt;br /&gt;
&lt;br /&gt;
还是那句话，不管是什么，标识符应该是独一无二的。不能说两个人共用一个sfz号。&lt;br /&gt;
&lt;br /&gt;
确切来说，标识符并不是你的按钮行为名，所以你可以选一个独一无二的字符串捏。&lt;br /&gt;
&lt;br /&gt;
这边推荐使用独一无二的东西当标识符前缀，比如你的用户名一样。否则有别人拓展模组用的标识符和你一样那不就冲突了（&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public ExampleButtonActionContainerWithValue() {&lt;br /&gt;
    //The action identifier needs to be unique, so just use your username or something similar as prefix&lt;br /&gt;
    //这儿处需要唯一的行为标识符，把你的用户名或者其他的东西当标识符前缀不就得了。&lt;br /&gt;
    super(&amp;quot;super_unique_action_identifier&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== getAction() ====&lt;br /&gt;
这个方法会返回你的按钮行为的名称。&lt;br /&gt;
&lt;br /&gt;
这个名字会用在编辑器中，炫一个你喜欢的名字。&lt;br /&gt;
&lt;br /&gt;
当然，别你写行为本质是胖子，但你起的名字是瘦子就行。&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//The name of your action. Should be lowercase and without any spaces.&lt;br /&gt;
//你的行为名都得小写不带空格。&lt;br /&gt;
@Override&lt;br /&gt;
public String getAction() {&lt;br /&gt;
    return &amp;quot;customaction&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== hasValue() ====&lt;br /&gt;
在这里你可以设定你的按钮行为是否需要值。&lt;br /&gt;
&lt;br /&gt;
譬如，打开GUI按钮行为就需要菜单标识符作为值。&lt;br /&gt;
&lt;br /&gt;
相对地，关闭GUI按钮行为就不需要值。&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//If the custom action has a value or not&lt;br /&gt;
//自定义行为是否需要值&lt;br /&gt;
@Override&lt;br /&gt;
public boolean hasValue() {&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== execute(..) ====&lt;br /&gt;
这是这个类里最重要的方法。&lt;br /&gt;
&lt;br /&gt;
这个方法是你用来创建按钮行为最基础的工具。&lt;br /&gt;
&lt;br /&gt;
它会在按下绑定了自定义行为的自定义按钮后被调用。（来点被字地狱：当被绑定了，自定义按钮行为的，自定义按钮，被按下时，它会被调用。）&lt;br /&gt;
&lt;br /&gt;
这里将按钮行为的值作为参数。&lt;br /&gt;
&lt;br /&gt;
参数可以为空，留意一下。&lt;br /&gt;
&lt;br /&gt;
所有你的按钮行为在按钮点击后都应该会被这个方法处理。&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//Gets called when a button with this custom action is getting clicked&lt;br /&gt;
//当单击具有此自定义行为的按钮时调用。&lt;br /&gt;
@Override&lt;br /&gt;
public void execute(String value) {&lt;br /&gt;
&lt;br /&gt;
    //This will open a new instance of the dirt message screen, when a button with this custom action is getting clicked&lt;br /&gt;
    //当带有自定义行为的按钮被点击后会打开一个新的泥土信息屏实例。&lt;br /&gt;
    //and will show the action value as message&lt;br /&gt;
    //并且会通过信息显示值。&lt;br /&gt;
    if (value != null) {&lt;br /&gt;
        Minecraft.getInstance().setScreen(new GenericDirtMessageScreen(new TextComponent(value)));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== getActionDescription() ====&lt;br /&gt;
你可以用这个方法描述你的按钮行为。&lt;br /&gt;
&lt;br /&gt;
它会在布局编辑器显示。&lt;br /&gt;
&lt;br /&gt;
重要: 越短越好，因为描述没那么多地方显示。&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//The description of the action&lt;br /&gt;
//行为的描述&lt;br /&gt;
@Override&lt;br /&gt;
public String getActionDescription() {&lt;br /&gt;
    return &amp;quot;Show custom text in a dirt message screen.&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== getValueDescription() ====&lt;br /&gt;
你的按钮行为值的描述。&lt;br /&gt;
&lt;br /&gt;
你的按钮行为如果有值，那你得稍微详细地描述你的值是啥。&lt;br /&gt;
&lt;br /&gt;
值描述和类型描述差不多。&lt;br /&gt;
&lt;br /&gt;
如果你的按钮行为没有值，那你返回&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;得了。&lt;br /&gt;
&lt;br /&gt;
重要: 越短越好，至于为啥，和上面一样。（暴躁）&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//The action has a value, so I return a simple and short value description here.&lt;br /&gt;
//如果行为有值，那返回简练的描述就行。&lt;br /&gt;
//This is actually more like a value type description.&lt;br /&gt;
//和变量类型描述差不多。&lt;br /&gt;
@Override&lt;br /&gt;
public String getValueDescription() {&lt;br /&gt;
    return &amp;quot;Display Text&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== getValueExample() ====&lt;br /&gt;
这个方法会返回一个按钮行为的值应该是什么样子的示例。&lt;br /&gt;
&lt;br /&gt;
没值返回空。（耐心↓）&lt;br /&gt;
&lt;br /&gt;
重要: 越短越好....(你知道我想说什么。（捂面）)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//That&amp;#039;s an example of how the action value should look like.&lt;br /&gt;
//行为值长这样 （指样例）&lt;br /&gt;
@Override&lt;br /&gt;
public String getValueExample() {&lt;br /&gt;
    //Well, it&amp;#039;s just a simple String, so what should be the example here &amp;gt;.&amp;lt;&lt;br /&gt;
    //简简单单的字符串，塞一点示例。&lt;br /&gt;
    return &amp;quot;cool text to display&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== 完整样例 ====&lt;br /&gt;
完整的&amp;lt;code&amp;gt;ButtonActionContainer&amp;lt;/code&amp;gt;样例。&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
package de.keksuccino.fancymenu.api.buttonaction.example;&lt;br /&gt;
&lt;br /&gt;
import de.keksuccino.fancymenu.api.buttonaction.ButtonActionContainer;&lt;br /&gt;
import net.minecraft.client.Minecraft;&lt;br /&gt;
import net.minecraft.client.gui.screens.GenericDirtMessageScreen;&lt;br /&gt;
import net.minecraft.network.chat.TextComponent;&lt;br /&gt;
&lt;br /&gt;
public class ExampleButtonActionContainerWithValue extends ButtonActionContainer {&lt;br /&gt;
&lt;br /&gt;
    public ExampleButtonActionContainerWithValue() {&lt;br /&gt;
        //The action identifier needs to be unique, so just use your username or something similar as prefix&lt;br /&gt;
        //这儿处需要唯一的行为标识符，把你的用户名或者其他的东西当标识符前缀不就得了。&lt;br /&gt;
        super(&amp;quot;super_unique_action_identifier&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //The name of your action. Should be lowercase and without any spaces.&lt;br /&gt;
    //你的行为名都得小写不带空格。&lt;br /&gt;
    @Override&lt;br /&gt;
    public String getAction() {&lt;br /&gt;
        return &amp;quot;customaction&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //If the custom action has a value or not&lt;br /&gt;
    //自定义行为是否有值&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean hasValue() {&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //Gets called when a button with this custom action is getting clicked&lt;br /&gt;
    //当单击具有此自定义行为的按钮时调用。&lt;br /&gt;
    @Override&lt;br /&gt;
    public void execute(String value) {&lt;br /&gt;
&lt;br /&gt;
        //This will open a new instance of the dirt message screen, when a button with this custom action is getting clicked&lt;br /&gt;
        //当带有自定义行为的按钮被点击后会打开一个新的泥土信息屏实例。&lt;br /&gt;
        //and will show the action value as message&lt;br /&gt;
        //并且还会以信息方式显示行为值。&lt;br /&gt;
        if (value != null) {&lt;br /&gt;
            Minecraft.getInstance().setScreen(new GenericDirtMessageScreen(new TextComponent(value)));&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //The description of the action&lt;br /&gt;
    //行为的描述&lt;br /&gt;
    @Override&lt;br /&gt;
    public String getActionDescription() {&lt;br /&gt;
        return &amp;quot;Show custom text in a dirt message screen.&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //The action has a value, so I return a simple and short value description here.&lt;br /&gt;
    //行为有值，所以得在这返回一段简练的值的描述。&lt;br /&gt;
    //This is actually more like a value type description.&lt;br /&gt;
    //更像是像值类型的描述。&lt;br /&gt;
    @Override&lt;br /&gt;
    public String getValueDescription() {&lt;br /&gt;
        return &amp;quot;Display Text&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //That&amp;#039;s an example of how the action value should look like.&lt;br /&gt;
    //行为值长这样 （指样例）&lt;br /&gt;
    @Override&lt;br /&gt;
    public String getValueExample() {&lt;br /&gt;
        //Well, it&amp;#039;s just a simple String, so what should be the example here &amp;gt;.&amp;lt;&lt;br /&gt;
        //简简单单的字符串，就像清清淡淡的人生。&lt;br /&gt;
        return &amp;quot;cool text to display&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== 注册Container ===&lt;br /&gt;
你几乎要完成了，就差一步，（坠入深渊无法生还）很重要的一步。&lt;br /&gt;
&lt;br /&gt;
FancyMenu得认你按钮行为，所以在你的拓展模组初始化时，你得在这个充满了注册的游戏中，注册你的&amp;lt;code&amp;gt;ButtonActionContainer&amp;lt;/code&amp;gt;到&amp;lt;code&amp;gt;ButtonActionRegistry&amp;lt;/code&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
package de.keksuccino.fancymenu;&lt;br /&gt;
&lt;br /&gt;
import net.minecraftforge.fml.common.Mod;&lt;br /&gt;
import de.keksuccino.fancymenu.api.buttonaction.ButtonActionRegistry;&lt;br /&gt;
&lt;br /&gt;
@Mod(&amp;quot;modid&amp;quot;)&lt;br /&gt;
public class ExampleModMainClass {&lt;br /&gt;
    public ExampleModMainClass() {&lt;br /&gt;
        try {&lt;br /&gt;
&lt;br /&gt;
            //Register your ButtonActionContainer to the ButtonActionRegistry at mod init.&lt;br /&gt;
            //在初始化中注册ButtonActionContainer到ButtonActionRegistry&lt;br /&gt;
            ButtonActionRegistry.registerButtonAction(new ExampleButtonActionContainerWithValue());&lt;br /&gt;
&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
现在你可以通过使用自定义按钮使用自定义按钮行为了。&lt;/div&gt;</summary>
		<author><name>Litwak913</name></author>
	</entry>
</feed>