UID2143386性别保密经验 EP铁粒 粒回帖0主题精华在线时间 小时注册时间2025-8-3最后登录1970-1-1
|
发表于 2025-11-23 01:46:54 来自手机|显示全部楼层 IP:江苏省文档
这个是官方文档,不过目前我也不知道有没有你说的那种工具,遂用ai写了一个
复制下面这一段,放到浏览器运行即可
- <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Minecraft 配方 JSON 生成器</title><style>
- body {
- font-family: Arial, sans-serif;
- margin: 2em;
- background: #f9f9f9;
- color: #333;
- }
- h1, h2 {
- color: #2c3e50;
- }
- .container {
- max-width: 800px;
- margin: auto;
- background: white;
- padding: 2em;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- }
- .form-group {
- margin-bottom: 1em;
- }
- label {
- display: block;
- margin-bottom: 0.5em;
- font-weight: bold;
- }
- input, select, textarea {
- width: 100%;
- padding: 0.5em;
- font-size: 1em;
- border: 1px solid #ccc;
- border-radius: 4px;
- }
- textarea {
- height: 100px;
- resize: vertical;
- }
- button {
- padding: 0.75em 1.5em;
- background: #3498db;
- color: white;
- border: none;
- border-radius: 4px;
- font-size: 1em;
- cursor: pointer;
- }
- button:hover {
- background: #2980b9;
- }
- .output {
- margin-top: 2em;
- background: #f1f1f1;
- padding: 1em;
- border-radius: 4px;
- white-space: pre-wrap;
- font-family: monospace;
- border: 1px solid #ddd;
- }
- .hidden {
- display: none;
- }
- </style></head><body><div class="container"><h1>🧱 Minecraft 配方 JSON 生成器</h1><p>填写下方信息,快速生成 Minecraft 食谱(配方)JSON!</p><form id="recipeForm"><!-- 基础信息 --><div class="form-group"><label for="recipeType">配方类型 *</label><select id="recipeType" required><option value="">请选择配方类型</option><option value="shaped">Shaped(有形状配方)</option><option value="shapeless">Shapeless(无形状配方)</option><option value="furnace">Furnace(熔炉配方)</option><option value="potion">Potion Brewing(药水酿造)</option><option value="smithing_transform">Smithing Transform(锻造升级)</option><option value="smithing_trim">Smithing Trim(锻造装饰)</option></select></div><!-- 通用字段 --><div class="form-group"><label for="inputItems">输入物品(用英文逗号分隔,如:minecraft:wood,minecraft:stick)*</label><input type="text" id="inputItems" placeholder="minecraft:oak_log,minecraft:stick" required></div><div class="form-group"><label for="outputItem">输出物品(格式:minecraft:item_id)*</label><input type="text" id="outputItem" placeholder="minecraft:oak_planks" required></div><!-- Shaped 配方特有 --><div id="shapedFields" class="hidden"><div class="form-group"><label for="pattern">图案(3x3,用空格和字符表示,如:ABC\nDEF\nGHI,每行不超过3个字符)</label><textarea id="pattern" placeholder="A B
- C D
- (每行用换行分隔,字符对应下方Key)"></textarea></div><div class="form-group"><label for="keyMapping">键位映射(格式:A=minecraft:wood,B=minecraft:stone,每行一个)</label><textarea id="keyMapping" placeholder="A=minecraft:oak_log
- B=minecraft:stick"></textarea></div></div><!-- Shapeless 配方特有 --><div id="shapelessFields" class="hidden"><div class="form-group"><label for="ingredientsOrder">原料顺序(可选,用逗号分隔,如不关心顺序可不填)</label><input type="text" id="ingredientsOrder" placeholder="minecraft:wood,minecraft:stone (顺序不影响)"></div></div><!-- Furnace 配方特有 --><div id="furnaceFields" class="hidden"><div class="form-group"><label for="furnaceType">熔炉类型(Furnace / Blast Furnace / Smoker,可选)</label><input type="text" id="furnaceType" placeholder="Furnace"></div></div><!-- Potion 配方特有 --><div id="potionFields" class="hidden"><div class="form-group"><label for="reagentItem">药剂材料(和输入分开,比如红石/烈焰粉,格式:minecraft:redstone)</label><input type="text" id="reagentItem" placeholder="minecraft:redstone"></div></div><!-- Smithing Transform 特有 --><div id="smithingTransformFields" class="hidden"><div class="form-group"><label for="baseItem">基础物品(将被保留属性的物品,如铁剑)</label><input type="text" id="baseItem" placeholder="minecraft:iron_sword"></div><div class="form-group"><label for="additionItem">添加物品(用来升级的物品,如钻石)</label><input type="text" id="additionItem" placeholder="minecraft:diamond"></div></div><!-- Smithing Trim 特有 --><div id="smithingTrimFields" class="hidden"><div class="form-group"><label for="trimMaterial">装饰材料(如:minecraft:iron_ingot)</label><input type="text" id="trimMaterial" placeholder="minecraft:iron_ingot"></div><div class="form-group"><label for="trimPattern">装饰图案(如:minecraft:tripwire_hook)</label><input type="text" id="trimPattern" placeholder="minecraft:tripwire_hook"></div></div><!-- 解锁条件(可选) --><div class="form-group"><label for="unlockContext">解锁条件(可选,如:AlwaysUnlocked、PlayerHasManyItems,留空则不设置)</label><input type="text" id="unlockContext" placeholder="AlwaysUnlocked 或 PlayerHasManyItems"></div><button type="button" onclick="generateRecipe()">🎯 生成配方 JSON</button><div class="form-group"><label>生成的配方 JSON:</label><div id="output" class="output">填写信息并点击生成...</div></div></form></div><script>
- // 根据配方类型显示对应字段
- document.getElementById('recipeType').addEventListener('change', function() {
- const type = this.value;
- const fields = ['shapedFields', 'shapelessFields', 'furnaceFields', 'potionFields', 'smithingTransformFields', 'smithingTrimFields'];
- fields.forEach(id => {
- document.getElementById(id).classList.add('hidden');
- });
- if (type === 'shaped') document.getElementById('shapedFields').classList.remove('hidden');
- if (type === 'shapeless') document.getElementById('shapelessFields').classList.remove('hidden');
- if (type === 'furnace') document.getElementById('furnaceFields').classList.remove('hidden');
- if (type === 'potion') document.getElementById('potionFields').classList.remove('hidden');
- if (type === 'smithing_transform') document.getElementById('smithingTransformFields').classList.remove('hidden');
- if (type === 'smithing_trim') document.getElementById('smithingTrimFields').classList.remove('hidden');
- });
- // 生成配方 JSON
- function generateRecipe() {
- const type = document.getElementById('recipeType').value;
- const inputItems = document.getElementById('inputItems').value.trim();
- const outputItem = document.getElementById('outputItem').value.trim();
- const unlockContext = document.getElementById('unlockContext').value.trim();
- if (!type || !inputItems || !outputItem) {
- alert('请至少填写配方类型、输入物品和输出物品!');
- return;
- }
- let recipe = {
- type: `minecraft:${type}_recipe`, // 通常格式,部分类型可能略有不同
- description: {
- identifier: `recipe:example/${type}_${Date.now()}`
- },
- tags: [],
- input: inputItems.split(',').map(s => s.trim()),
- output: outputItem
- };
- // Shaped
- if (type === 'shaped') {
- recipe.pattern = document.getElementById('pattern').value.trim().split('\n').filter(Boolean);
- recipe.key = {};
- const keyMappings = document.getElementById('keyMapping').value.trim().split('\n');
- keyMappings.forEach(line => {
- const [key, value] = line.split('=').map(s => s.trim());
- if (key && value) recipe.key[key] = { item: value };
- });
- }
- // Shapeless
- if (type === 'shapeless') {
- recipe.ingredients = inputItems.split(',').map(s => ({ item: s.trim() }));
- }
- // Furnace
- if (type === 'furnace') {
- recipe.input = inputItems.split(',').map(s => s.trim());
- recipe.output = outputItem;
- recipe.cooking_time = 200; // 默认
- if (document.getElementById('furnaceType').value.trim())
- recipe.type = `minecraft:${document.getElementById('furnaceType').value.trim()}_recipe`;
- }
- // Potion
- if (type === 'potion') {
- recipe.input = inputItems.split(',').map(s => s.trim());
- recipe.reagent = document.getElementById('reagentItem').value.trim();
- recipe.output = outputItem;
- }
- // Smithing Transform
- if (type === 'smithing_transform') {
- recipe.base = document.getElementById('baseItem').value.trim();
- recipe.addition = document.getElementById('additionItem').value.trim();
- recipe.result = outputItem;
- }
- // Smithing Trim
- if (type === 'smithing_trim') {
- recipe.base = inputItems.split(',').map(s => s.trim())[0]; // 假设第一个是基础物品
- recipe.material = document.getElementById('trimMaterial').value.trim();
- recipe.pattern = document.getElementById('trimPattern').value.trim();
- recipe.output = outputItem;
- }
- // 解锁条件
- if (unlockContext) {
- recipe.unlock = unlockContext === 'AlwaysUnlocked' ? { context: 'AlwaysUnlocked' } : { context: unlockContext };
- }
- // 显示结果
- document.getElementById('output').textContent = JSON.stringify(recipe, null, 2);
- }
- </script></body></html>
复制代码 |

2#2025-11-23 01:46:54回复(0)收起回复 |