Creeprchain
安装与构建请访问 GitHub
适用于 Minecraft Fabric 1.20.1 的经济模组。玩家可在 ATM 方块中存入物品,并在以太坊兼容区块链上获得类 ERC-20 代币。代币可在 MetaMask 中查看。
环境要求
| 工具 |
版本 |
| Java JDK |
21 |
| Fabric Loader |
0.19.2 |
| Fabric API |
0.92.9+1.20.1 |
| Node.js |
18+(用于 Hardhat) |
| Hardhat |
已安装于 blockchain/ 目录 |
构建模组
./gradlew build
输出 jar 包位于:
build/libs/creeprchain-1.0.0.jar
Windows 用户请使用 gradlew.bat build
在 Fabric 服务端安装
- 下载 Fabric Installer 并为 Minecraft 1.20.1 安装 Fabric 服务端。
- 将
build/libs/creeprchain-1.0.0.jar 复制到服务端的 mods/ 文件夹中。
- 下载适用于 1.20.1 的 Fabric API 并同样放入
mods/ 目录。
- 启动服务端一次——这将创建配置文件目录
config/creeprchain/。
- 编辑
config/creeprchain/blockchain.json(参见 区块链设置)。
- 重启服务端。
在客户端安装
- 在游戏启动器中为 Minecraft 1.20.1 安装 Fabric Loader。
- 将
build/libs/creeprchain-1.0.0.jar 复制到 .minecraft/mods/ 目录。
- 将适用于 1.20.1 的 Fabric API 也复制到
.minecraft/mods/ 目录。
- 启动游戏并连接至服务器。
客户端和服务端必须使用完全相同的 jar 包。版本不匹配会导致注册表同步错误(missing creeprchain:atm_block)。
区块链设置(已在 LINUX 上测试)
区块链运行在一台独立的 Linux 机器上。以下所有命令均在该机器的 blockchain/ 文件夹内执行。
步骤 1 — 安装依赖项
cd blockchain
npm install
步骤 2 — 启动 Hardhat 节点
scripts/start-local-chain.sh
这将在 0.0.0.0:8545 启动一个本地以太坊节点(链 ID 31337)。请保持此终端窗口开启。
步骤 3 — 部署合约
在同一台机器上打开第二个终端窗口:
scripts/deploy-contract.sh
输出示例:
Token deployed to: 0xAbCd1234...
复制合约地址。
步骤 4 — 配置 blockchain.json
在 Minecraft 服务端机器 上,编辑 config/creeprchain/blockchain.json:
{
"rpcUrl": "http://192.168.0.108:8545",
"chainId": 31337,
"contractAddress": "0xAbCd1234...",
"privateKey": "0xd345b787fa175fa22321746c8e0289ad88eac2de8c39ce67215c8b362af621e5"
}
rpcUrl — 运行 Hardhat 节点的 Linux 机器的 IP 地址
contractAddress — 部署脚本打印出的地址
privateKey — Hardhat 部署者账户;该钱包代表服务端签署铸造/销毁交易
重启 Minecraft 服务端。日志中将显示:
BlockchainService connected: rpc=http://192.168.0.108:8545 chainId=31337 contract=0x...
MetaMask 设置
- 打开 MetaMask → 设置 → 网络 → 手动添加网络:
- RPC URL:
http://192.168.0.108:8545
- Chain ID:
31337
- 货币符号: ETH
- 添加代币:MetaMask → 代币 → 导入代币 → 粘贴合约地址。
- 记录你的 MetaMask 钱包地址——你将使用它配合
/linkwallet 命令。
游戏内设置与测试
/linkwallet 0xYourMetaMaskAddress
放置一个 ATM 方块(使用 /give @p creeprchain:atm_block),手持钻石(或其他已配置的物品)右键点击该方块。代币将出现在 MetaMask 中。
命令
| 命令 |
描述 |
/linkwallet <address> |
将你的 Minecraft 账号绑定到以太坊钱包地址 |
/balance |
显示你的代币余额 |
/send <player> <amount> |
向其他在线玩家转移代币 |
/withdraw <amount> |
销毁代币(从区块链提现) |
/withdraw <item> <count> |
销毁代币并获得 Minecraft 物品 |
配置
配置文件位于服务端的 config/creeprchain/ 目录下。如果文件不存在,则使用内置在 src/main/resources/config/ 中的默认值。
economy.json — 存入与取出汇率
{
"depositRates": {
"minecraft:diamond": 100,
"minecraft:iron_ingot": 10,
"minecraft:gold_ingot": 20
},
"withdrawRates": {
"minecraft:diamond": 95,
"minecraft:iron_ingot": 9,
"minecraft:gold_ingot": 18
},
"maxDeposit": 10000,
"maxWithdraw": 5000,
"maxBalance": 100000
}
blockchain.json — 连接到以太坊节点
{
"rpcUrl": "http://192.168.0.108:8545",
"chainId": 31337,
"contractAddress": "0x0000000000000000000000000000000000000000",
"privateKey": ""
}
如果 privateKey 为空或 contractAddress 为零,模组将以 本地账本模式 运行(交易仅存储在 SQLite 中,不与区块链交互)。
许可证
MIT
Creeprchain
for installation and building, visit github
Minecraft Fabric 1.20.1 economy mod. Players deposit items at an ATM block and receive ERC-20-style tokens on an Ethereum-compatible blockchain. Tokens are visible in MetaMask.
Requirements
| Tool |
Version |
| Java JDK |
21 |
| Fabric Loader |
0.19.2 |
| Fabric API |
0.92.9+1.20.1 |
| Node.js |
18+ (for Hardhat) |
| Hardhat |
installed in blockchain/ |
Building the mod
./gradlew build
The output jar is at:
build/libs/creeprchain-1.0.0.jar
On Windows use gradlew.bat build
Installing on a Fabric server
- Download Fabric Installer and install Fabric server for Minecraft 1.20.1.
- Copy
build/libs/creeprchain-1.0.0.jar into the server's mods/ folder.
- Download Fabric API for 1.20.1 and place it in
mods/ as well.
- Start the server once — it will create the config directory at
config/creeprchain/.
- Edit
config/creeprchain/blockchain.json (see Blockchain setup).
- Restart the server.
Installing on a client
- Install Fabric Loader for Minecraft 1.20.1 in the launcher.
- Copy
build/libs/creeprchain-1.0.0.jar into .minecraft/mods/.
- Copy Fabric API for 1.20.1 into
.minecraft/mods/ as well.
- Launch the game and connect to the server.
The client and server must use the exact same jar. A version mismatch causes registry sync errors (missing creeprchain:atm_block).
Blockchain setup (tested on LINUX)
The blockchain runs on a separate Linux machine. All commands below are run on that machine inside the blockchain/ folder.
Step 1 — Install dependencies
cd blockchain
npm install
Step 2 — Start Hardhat node
scripts/start-local-chain.sh
This starts a local Ethereum node at 0.0.0.0:8545 (chain ID 31337). Leave this terminal open.
Step 3 — Deploy the contract
Open a second terminal on the same machine:
scripts/deploy-contract.sh
Output example:
Token deployed to: 0xAbCd1234...
Copy the contract address.
Step 4 — Configure blockchain.json
On the Minecraft server machine, edit config/creeprchain/blockchain.json:
{
"rpcUrl": "http://192.168.0.108:8545",
"chainId": 31337,
"contractAddress": "0xAbCd1234...",
"privateKey": "0xd345b787fa175fa22321746c8e0289ad88eac2de8c39ce67215c8b362af621e5"
}
rpcUrl — IP of the Linux machine running the Hardhat node
contractAddress — address printed by the deploy script
privateKey — the Hardhat deployer account; this wallet signs mint/burn transactions on behalf of the server
Restart the Minecraft server. The log will show:
BlockchainService connected: rpc=http://192.168.0.108:8545 chainId=31337 contract=0x...
MetaMask setup
- Open MetaMask → Settings → Networks → Add network manually:
- RPC URL:
http://192.168.0.108:8545
- Chain ID:
31337
- Currency symbol: ETH
- Add the token: MetaMask → Tokens → Import token → paste the contract address.
- Note your MetaMask wallet address — you will use it with
/linkwallet.
In-game setup and test
/linkwallet 0xYourMetaMaskAddress
Place an ATM block (/give @p creeprchain:atm_block) and right-click it while holding a diamond (or another configured item). The tokens will appear in MetaMask.
Commands
| Command |
Description |
/linkwallet <address> |
Bind your Minecraft account to an Ethereum wallet address |
/balance |
Show your token balance |
/send <player> <amount> |
Transfer tokens to another online player |
/withdraw <amount> |
Burn tokens (blockchain withdraw) |
/withdraw <item> <count> |
Burn tokens and receive Minecraft items |
Configuration
Config files live in config/creeprchain/ on the server. If absent, bundled defaults from src/main/resources/config/ are used.
economy.json — deposit and withdraw rates
{
"depositRates": {
"minecraft:diamond": 100,
"minecraft:iron_ingot": 10,
"minecraft:gold_ingot": 20
},
"withdrawRates": {
"minecraft:diamond": 95,
"minecraft:iron_ingot": 9,
"minecraft:gold_ingot": 18
},
"maxDeposit": 10000,
"maxWithdraw": 5000,
"maxBalance": 100000
}
blockchain.json — connection to the Ethereum node
{
"rpcUrl": "http://192.168.0.108:8545",
"chainId": 31337,
"contractAddress": "0x0000000000000000000000000000000000000000",
"privateKey": ""
}
If privateKey is empty or contractAddress is zero, the mod runs in local-ledger mode (transactions stored only in SQLite, no blockchain interaction).
License
MIT
评论 0
登录后参与评分
还没有评论,来抢沙发吧