diff --git a/data/bedrock/0.15/protocol.json b/data/bedrock/0.15/protocol.json index d3c3a194f..2aad29c49 100644 --- a/data/bedrock/0.15/protocol.json +++ b/data/bedrock/0.15/protocol.json @@ -631,7 +631,8 @@ "0x3c": "request_chunk_radius", "0x3d": "chunk_radius_update", "0x3a": "spawn_experience_orb", - "0x3f": "replace_selected_item" + "0x3f": "replace_selected_item", + "0x55": "transfer" } } ] diff --git a/data/bedrock/1.16.201/proto.yml b/data/bedrock/1.16.201/proto.yml index 169629cfc..e208b0e9b 100644 --- a/data/bedrock/1.16.201/proto.yml +++ b/data/bedrock/1.16.201/proto.yml @@ -1283,7 +1283,7 @@ packet_boss_event: _: type? if register_player or unregister_player: player_id: zigzag64 - if show: + if show_bar: title: string bar_progress: lf32 if update_properties: diff --git a/data/bedrock/1.16.201/protocol.json b/data/bedrock/1.16.201/protocol.json index 56d0d25f0..8c1aeb267 100644 --- a/data/bedrock/1.16.201/protocol.json +++ b/data/bedrock/1.16.201/protocol.json @@ -5248,7 +5248,7 @@ } ] ], - "show": [ + "show_bar": [ "container", [ { diff --git a/data/bedrock/1.16.210/proto.yml b/data/bedrock/1.16.210/proto.yml index f53f9b8da..5fa587538 100644 --- a/data/bedrock/1.16.210/proto.yml +++ b/data/bedrock/1.16.210/proto.yml @@ -1322,7 +1322,7 @@ packet_boss_event: _: type? if register_player or unregister_player: player_id: zigzag64 - if show: + if show_bar: title: string bar_progress: lf32 if update_properties: diff --git a/data/bedrock/1.16.210/protocol.json b/data/bedrock/1.16.210/protocol.json index 9928544e6..d4613ec2e 100644 --- a/data/bedrock/1.16.210/protocol.json +++ b/data/bedrock/1.16.210/protocol.json @@ -5547,7 +5547,7 @@ } ] ], - "show": [ + "show_bar": [ "container", [ { diff --git a/data/pc/1.20.5/proto.yml b/data/pc/1.20.5/proto.yml index 70baf3762..aa0699d30 100644 --- a/data/pc/1.20.5/proto.yml +++ b/data/pc/1.20.5/proto.yml @@ -2252,6 +2252,7 @@ - minecraft:crafting_special_firework_star_fade - minecraft:crafting_special_tippedarrow - minecraft:crafting_special_bannerduplicate + - minecraft:crafting_special_banneraddpattern - minecraft:crafting_special_shielddecoration - minecraft:crafting_special_shulkerboxcoloring - minecraft:crafting_special_suspiciousstew diff --git a/data/pc/1.20.5/protocol.json b/data/pc/1.20.5/protocol.json index f58c75027..7540566b7 100644 --- a/data/pc/1.20.5/protocol.json +++ b/data/pc/1.20.5/protocol.json @@ -6891,18 +6891,19 @@ "8": "minecraft:crafting_special_firework_star_fade", "9": "minecraft:crafting_special_tippedarrow", "10": "minecraft:crafting_special_bannerduplicate", - "11": "minecraft:crafting_special_shielddecoration", - "12": "minecraft:crafting_special_shulkerboxcoloring", - "13": "minecraft:crafting_special_suspiciousstew", - "14": "minecraft:crafting_special_repairitem", - "15": "minecraft:smelting", - "16": "minecraft:blasting", - "17": "minecraft:smoking", - "18": "minecraft:campfire_cooking", - "19": "minecraft:stonecutting", - "20": "minecraft:smithing_transform", - "21": "minecraft:smithing_trim", - "22": "minecraft:crafting_decorated_pot" + "11": "minecraft:crafting_special_banneraddpattern", + "12": "minecraft:crafting_special_shielddecoration", + "13": "minecraft:crafting_special_shulkerboxcoloring", + "14": "minecraft:crafting_special_suspiciousstew", + "15": "minecraft:crafting_special_repairitem", + "16": "minecraft:smelting", + "17": "minecraft:blasting", + "18": "minecraft:smoking", + "19": "minecraft:campfire_cooking", + "20": "minecraft:stonecutting", + "21": "minecraft:smithing_transform", + "22": "minecraft:smithing_trim", + "23": "minecraft:crafting_decorated_pot" } } ] diff --git a/data/pc/1.21.1/proto.yml b/data/pc/1.21.1/proto.yml index 41118900b..686cac589 100644 --- a/data/pc/1.21.1/proto.yml +++ b/data/pc/1.21.1/proto.yml @@ -2304,6 +2304,7 @@ - minecraft:crafting_special_firework_star_fade - minecraft:crafting_special_tippedarrow - minecraft:crafting_special_bannerduplicate + - minecraft:crafting_special_banneraddpattern - minecraft:crafting_special_shielddecoration - minecraft:crafting_special_shulkerboxcoloring - minecraft:crafting_special_suspiciousstew diff --git a/data/pc/1.21.1/protocol.json b/data/pc/1.21.1/protocol.json index cbeb0693d..52f3942cc 100644 --- a/data/pc/1.21.1/protocol.json +++ b/data/pc/1.21.1/protocol.json @@ -7071,18 +7071,19 @@ "8": "minecraft:crafting_special_firework_star_fade", "9": "minecraft:crafting_special_tippedarrow", "10": "minecraft:crafting_special_bannerduplicate", - "11": "minecraft:crafting_special_shielddecoration", - "12": "minecraft:crafting_special_shulkerboxcoloring", - "13": "minecraft:crafting_special_suspiciousstew", - "14": "minecraft:crafting_special_repairitem", - "15": "minecraft:smelting", - "16": "minecraft:blasting", - "17": "minecraft:smoking", - "18": "minecraft:campfire_cooking", - "19": "minecraft:stonecutting", - "20": "minecraft:smithing_transform", - "21": "minecraft:smithing_trim", - "22": "minecraft:crafting_decorated_pot" + "11": "minecraft:crafting_special_banneraddpattern", + "12": "minecraft:crafting_special_shielddecoration", + "13": "minecraft:crafting_special_shulkerboxcoloring", + "14": "minecraft:crafting_special_suspiciousstew", + "15": "minecraft:crafting_special_repairitem", + "16": "minecraft:smelting", + "17": "minecraft:blasting", + "18": "minecraft:smoking", + "19": "minecraft:campfire_cooking", + "20": "minecraft:stonecutting", + "21": "minecraft:smithing_transform", + "22": "minecraft:smithing_trim", + "23": "minecraft:crafting_decorated_pot" } } ] diff --git a/data/pc/26.1/protocol.json b/data/pc/26.1/protocol.json index dc7aeb844..41b64ae64 100644 --- a/data/pc/26.1/protocol.json +++ b/data/pc/26.1/protocol.json @@ -264,7 +264,7 @@ "96": "cow/sound_variant", "97": "chicken/variant", "98": "chicken/sound_variant", - "99": "zomie_nautilus/variant", + "99": "zombie_nautilus/variant", "100": "frog/variant", "101": "horse/variant", "102": "painting/variant", diff --git a/data/pc/latest/proto.yml b/data/pc/latest/proto.yml index 79e100ea2..e60b8ef51 100644 --- a/data/pc/latest/proto.yml +++ b/data/pc/latest/proto.yml @@ -165,7 +165,7 @@ - cow/sound_variant - chicken/variant - chicken/sound_variant - - zomie_nautilus/variant + - zombie_nautilus/variant - frog/variant - horse/variant - painting/variant diff --git a/tools/js/test/test.js b/tools/js/test/test.js index 3a17bbfd9..3079b2d17 100644 --- a/tools/js/test/test.js +++ b/tools/js/test/test.js @@ -18,6 +18,68 @@ after('the test suite stays fast', function () { assert.ok(ms < 40 * 1000, `the test suite took ${Math.round(ms)}ms, expected < 40s`) }) +function resolveType (type, types, seen = new Set()) { + if (typeof type === 'string' && types[type] && !seen.has(type)) { + seen.add(type) + return resolveType(types[type], types, seen) + } + return type +} + +function checkProtocolSwitches (protocol, versionString) { + const issues = [] + + function visitType (type, scope, location, active = new Set()) { + if (!Array.isArray(type) || active.has(type)) return + active.add(type) + const [kind, options] = type + if (kind === 'container' && Array.isArray(options)) { + const fields = { ...scope } + for (const field of options) { + if (!field || typeof field !== 'object') continue + const fieldType = resolveType(field.type, protocol.types) + if (Array.isArray(fieldType) && fieldType[0] === 'mapper') { + fields[field.name] = new Set(Object.values(fieldType[1].mappings || {})) + } + visitType(fieldType, fields, location + '/' + (field.name || '?'), active) + } + } else if (kind === 'switch' && options) { + const mapper = scope[options.compareTo] + if (mapper) { + for (const value of Object.keys(options.fields || {})) { + if (!mapper.has(value)) issues.push(`${location}: ${options.compareTo} -> ${value}`) + } + } else if (options.compareTo) { + console.log(`${versionString}: unable to find ${options.compareTo} for switch at ${location}`) + } + for (const [value, fieldType] of Object.entries(options.fields || {})) { + visitType(fieldType, scope, location + '/' + value, active) + } + if (options.default) visitType(options.default, scope, location + '/default', active) + } else if (kind === 'array' || kind === 'option') { + visitType(options && options.type, scope, location + '/type', active) + } else if (kind === 'registryEntryHolder') { + visitType(options && options.otherwise && options.otherwise.type, scope, location + '/otherwise', active) + } + active.delete(type) + } + + function visit (value, location) { + if (Array.isArray(value)) { + if (typeof value[0] === 'string' && ['container', 'switch', 'array', 'option', 'mapper', 'registryEntryHolder'].includes(value[0])) { + visitType(value, {}, location) + } else { + value.forEach((item, index) => visit(item, location + '/' + index)) + } + } else if (value && typeof value === 'object') { + Object.entries(value).forEach(([key, item]) => visit(item, location + '/' + key)) + } + } + + visit(protocol, versionString) + assert.deepEqual(issues, [], `${versionString} has switches with undefined mapper values:\n${issues.join('\n')}`) +} + const data = ['attributes', 'biomes', 'commands', 'instruments', 'items', 'materials', 'blocks', 'blockCollisionShapes', 'recipes', 'windows', 'entities', 'protocol', 'version', 'effects', 'enchantments', 'language', 'foods', 'particles', 'blockLoot', 'entityLoot', 'mapIcons', 'tints', 'blockMappings', 'sounds', 'blockStates'] require('./version_iterator')(function (p, versionString) { @@ -44,6 +106,7 @@ require('./version_iterator')(function (p, versionString) { validator.addType('entityMetadataItem', require('../../../schemas/protocol_types/entity_metadata_item.json')) validator.addType('entityMetadataLoop', require('../../../schemas/protocol_types/entity_metadata_loop.json')) validator.validateProtocol(instance) + checkProtocolSwitches(instance, versionString) } else { const schema = require('../../../schemas/' + dataName + '_schema.json') const valid = v.validate(schema, instance)