Minecraft 交易 GUI 数据包
一个功能强大、高度可定制的原版 Minecraft 交易商店系统数据包。
作者介绍
作者: YChenY5260
数据包简介
本数据包利用 Minecraft 的原版数据包功能以及 1.21.8+ 版本的新特性,实现了一个完全可定制的商店交易系统。你不再需要依赖村民!你可以创建自己的商店,将任意物品设为货币和商品,为其他玩家提供直观的图形界面(GUI)进行交易,且几乎无需编写繁琐的 Json 文件。
功能特性
- 商店创建与管理:使用专用工具生成商店实体,并自定义其名称、外观颜色及支持的页数。
- 双模式:
- 编辑模式:商店所有者可直接在商店界面中放置物品以设置交易。
- 开放模式:顾客可与商店进行交易。
- 多页系统:单个商店最多支持 30 页,便于组织大量交易。
- 复杂交易逻辑:支持一件物品兑换多种商品,以及需要多种货币的复杂交易。
- 视觉预处理:提供交易物品的“合成”系统。通过在箱子中放置物品自动生成复杂的交易物品,大幅简化设置流程。
- 强大的算法核心:内置自研算法库,支持循环、算术运算等高级功能,为系统提供强力支持。
使用说明
-
安装数据包
- 将下载的
.zip 文件放入你的世界对应的 datapacks 文件夹中(路径为 /.minecraft/saves/<你的世界名称>/datapacks/)。
- 在游戏中输入
/reload,或重新进入世界以加载该数据包。
- 出现成功提示即表示安装完成。
-
获取工具
- 在游戏中使用命令
/function give:<tool_name> 来获取工具。
工具名称可以是:
summon_trader: 召唤商人工具 - 用于创建一个新的商店实体
trader_mode_switcher: 商店模式切换器 - 用于在编辑模式和开放模式之间切换商店
trader_setting_tool: Trader Setting Tool - 用于设置基本商店信息(已弃用)
-
创建你的第一个商店
- 使用
Summon Trader Tool(召唤商人工具)。按照对话框提示输入商店名称、颜色和页数,以生成一个商店实体(带箱子的矿车)。
- 手持
Shop Mode Switcher(商店模式切换器)并右键点击商店,将其切换到 编辑模式(稍退后几步;成功切换的标志是商店上方出现文字提示)。
- 执行命令
/tag @s add editing 授予自己编辑权限。
- 右键点击打开商店界面。像整理箱子一样放置你想要出售的物品(交易物品)。如何获取交易物品? 见下方的“预处理系统”。
- 编辑完成后,再次使用
Shop Mode Switcher(商店模式切换器)切换回 开放模式。
- 执行命令
/tag @s remove editing 移除你的编辑权限。现在你可以右键点击打开商店并与之交易了!
提示:
- 在 编辑模式 下,你可以编辑商店的 GUI 边框(但切勿移除上一页和下一页按钮,尽管这并不推荐)。
-
预处理系统
- 将 普通箱子 放置在命令方块之上。
- 在命令方块中输入命令
function pre_process:chest_generator。
- 打开箱子并将物品放入对应的槽位:
- 第一行(第 0 号槽位):放置用于显示交易物品的“图标物品”(任意物品均可)
- 第二行(第 9-17 号槽位):放置顾客应 获得 的物品(最多 9 种类型)
- 第三行(第 18-26 号槽位):放置顾客应 支付 的物品(最多 9 种货币类型)
- 关闭箱子并激活命令方块(提供红石信号)。
- 重新打开箱子以收集生成的交易物品。将其放入你的商店界面中!
提示:
- 所有物品均支持自定义名称/描述文本
- 自定义货币需要唯一的
custom_data 组件
- 在取出交易物品前,请先给自己授予编辑权限(
/tag @s add editing)
-
交易流程
- 确保你 没有 编辑权限(
/tag @s remove editing)。打开“商店”。
- 携带足够的货币。点击你想要的商品(交易物品)。
- 成功:听到确认音效 + 获得商品 + 货币被消耗
- 失败:聊天栏显示货币不足(悬停查看详情)
高级用法与自定义
核心配置使用记分板和 Storage:
- 修改页数限制(默认值:30)
编辑 data/<namespace>/dialog/trader_summoner.json(需要 JSON 知识)
(高级自定义通常需要直接修改函数文件)
兼容性
- 需要 Minecraft Java Edition 1.21.8+(数据包 v81+)
- 使用 1.21.8 引入的对话系统
- 理论上兼容未来版本
许可证
MIT 许可证 - 可免费用于个人/商业用途,需注明出处。详见 LICENSE 文件。
Minecraft Trade GUI Datapack
A powerful, highly customizable vanilla Minecraft trading shop system datapack.
About the Author
Author: YChenY5260
Datapack Introduction
This datapack utilizes Minecraft's vanilla datapack capabilities and new features from version 1.21.8+ to implement a fully customizable shop trading system. You no longer need to rely on villagers! You can create your own shops, set any items as currency and goods, provide an intuitive GUI interface for other players to trade with, and it requires almost no writing of tedious Json files.
Features
- Shop Creation & Management: Use specific tools to generate shop entities and customize their name, appearance color, and number of supported pages.
- Dual Modes:
- Edit Mode: The shop owner can directly place items within the shop interface to set up trades.
- Open Mode: Customers can trade with the shop.
- Multi-Page System: A single shop supports up to 30 pages, making it easy to organize a large number of trades.
- Complex Trade Logic: Supports trading one item for multiple goods, and complex trades requiring multiple types of currency.
- Visual Preprocessing: Provides a trade item "crafting" system. Automatically generates complex trade items by placing items in a chest, greatly simplifying the setup process.
- Powerful Algorithm Core: Includes a self-developed algorithm library supporting loops, arithmetic operations, and other advanced features, providing strong support for the system.
Usage Instructions
-
Install the Datapack
- Place the downloaded
.zip file into the datapacks folder of your world (/.minecraft/saves/<Your World Name>/datapacks/).
- In-game, type
/reload or re-enter the world to load the datapack.
- A success message will indicate successful installation.
-
Obtain Tools
- Use the command
/function give:<tool_name> in-game to get tools.
Tool names can be:
summon_trader: Summon Trader Tool - Used to create a new shop entity
trader_mode_switcher: Shop Mode Switcher - Used to switch the shop between Edit and Open modes
trader_setting_tool: Trader Setting Tool - Used to set basic shop information (Deprecated)
-
Create Your First Shop
- Use the
Summon Trader Tool. Follow the dialog prompts to input the shop name, color, and number of pages to generate a shop entity (a Minecart with Chest).
- Hold the
Shop Mode Switcher and right-click the shop to switch it to Edit Mode (Move back a bit; successful switch is indicated by text above the shop).
- Use the command
/tag @s add editing to grant yourself editing permissions.
- Right-click to open the shop interface. Place the items you want to sell (trade items) as if organizing a chest. How to get trade items? See "Preprocessing System" below.
- After editing, use the
Shop Mode Switcher again to switch back to Open Mode.
- Use the command
/tag @s remove editing to remove your editing permissions. Now you can right-click to open the shop and trade with it!
Tips:
- In Edit Mode, you can edit the GUI border of the shop (but never remove the Previous Page and Next Page buttons, though it is not recommended.
-
Preprocessing System
- Place a regular chest on top of a command block.
- Write the command
function pre_process:chest_generator in the command block.
- Open the chest and place items in the corresponding slots:
- First Row (Slot 0): Place the desired "icon item" for the trade item display (any item)
- Second Row (Slots 9-17): Place items the customer should receive (up to 9 types)
- Third Row (Slots 18-26): Place items the customer should pay (up to 9 currency types)
- Close the chest and activate the command block (provide redstone power).
- Reopen the chest to collect the generated trade item. Place it in your shop interface!
Tips:
- All items support custom names/lore
- Custom currency requires unique
custom_data component
- Grant yourself editing permissions before taking trade items (
/tag @s add editing)
-
Trading Process
- Ensure you do not have editing permissions (
/tag @s remove editing). Open the "Shop".
- Carry sufficient currency. Click on the desired good (trade item).
- Success: Hear confirmation sound + receive goods + currency consumed
- Failure: Chat message shows missing currency (hover for details)
Advanced Usage & Customization
Core configuration uses scoreboards and Storage:
- Modify Page Limit (Default: 30)
Edit data/<namespace>/dialog/trader_summoner.json (requires JSON knowledge)
(Advanced customization typically requires direct function file modification)
Compatibility
- Requires Minecraft Java Edition 1.21.8+ (Datapack v81+)
- Uses Dialog system introduced in 1.21.8
- Theoretically compatible with future versions
License
MIT License - Free for personal/commercial use with attribution. See LICENSE file.
评论 0
登录后参与评分
还没有评论,来抢沙发吧