diff --git a/schemas/1.14.json b/schemas/1.14.json
index 5fc36d0b..2701e108 100644
--- a/schemas/1.14.json
+++ b/schemas/1.14.json
@@ -267,45 +267,7 @@
"id": "enchantments",
"type": "set",
"source": "enchantment",
- "values": [
- "minecraft:aqua_affinity",
- "minecraft:bane_of_arthropods",
- "minecraft:blast_protection",
- "minecraft:channeling",
- "minecraft:binding_curse",
- "minecraft:vanishing_curse",
- "minecraft:depth_strider",
- "minecraft:efficiency",
- "minecraft:feather_falling",
- "minecraft:fire_aspect",
- "minecraft:fire_protection",
- "minecraft:flame",
- "minecraft:fortune",
- "minecraft:frost_walker",
- "minecraft:impaling",
- "minecraft:infinity",
- "minecraft:knockback",
- "minecraft:looting",
- "minecraft:loyalty",
- "minecraft:luck_of_the_sea",
- "minecraft:lure",
- "minecraft:mending",
- "minecraft:multishot",
- "minecraft:piercing",
- "minecraft:power",
- "minecraft:projectile_protection",
- "minecraft:protection",
- "minecraft:punch",
- "minecraft:quick_charge",
- "minecraft:respiration",
- "minecraft:riptide",
- "minecraft:sharpness",
- "minecraft:silk_touch",
- "minecraft:smite",
- "minecraft:sweeping",
- "minecraft:thorns",
- "minecraft:unbreaking"
- ],
+ "values": "enchantments",
"require": [
"minecraft:enchant_randomly"
]
@@ -409,17 +371,32 @@
"minecraft:alternative",
"minecraft:inverted",
"minecraft:entity_properties",
- "minecraft:block_state_propery",
- "minecraft:match_tool",
- "minecraft:damage_source_properties",
+ {
+ "value": "minecraft:block_state_propery",
+ "require": ["minecraft:block"]
+ },
+ {
+ "value": "minecraft:match_tool",
+ "require": ["minecraft:block", "minecraft:fishing"]
+ },
+ {
+ "value": "minecraft:damage_source_properties",
+ "require": ["minecraft:entity"]
+ },
"minecraft:location_check",
"minecraft:weather_check",
"minecraft:entity_scores",
"minecraft:random_chance",
"minecraft:random_chance_with_looting",
- "minecraft:table_bonus",
+ {
+ "value": "minecraft:table_bonus",
+ "require": ["minecraft:block"]
+ },
"minecraft:killed_by_player",
- "minecraft:survives_explosion"
+ {
+ "value": "survives_explosion",
+ "require": ["minecraft:block"]
+ }
]
},
{
diff --git a/view.js b/view.js
index b78f180f..4e093356 100644
--- a/view.js
+++ b/view.js
@@ -5,10 +5,23 @@ let collections;
changeVersion('1.14');
function changeVersion(version) {
$.getJSON('schemas/' + version + '.json', json => {
- $('#versionLabel').text(version);
structure = json.root;
components = json.components;
collections = json.collections;
+ }).fail((jqXHR, textStatus, errorThrown) => {
+ let message = 'Failed loading ' + version + ' schema';
+ structure = {
+ fields: [
+ {
+ id: 'pools',
+ type: 'error',
+ message: message
+ }
+ ]
+ };
+ console.error(message + '\n' + errorThrown);
+ }).always(() => {
+ $('#versionLabel').text(version);
updateView();
});
}
@@ -56,7 +69,9 @@ function generateComponent(data, struct) {
case 'nbt': return generateNbt(data, struct);
case 'array': return generateArray(data, struct);
case 'object': return generateObject(data, struct, false);
- default: return generateError('Unknown component type "' + struct.type + '"')};
+ case 'error': return generateError(struct);
+ default: return generateError('Unknown component type "' + struct.type + '"');
+ }
}
function generateString(data, struct) {
@@ -138,7 +153,14 @@ function generateEnum(data, struct) {
$el.find('select').append(setValueAndName($(''), 'unset', undefined));
}
for (let value of collection) {
- $el.find('select').append(setValueAndName($(''), value, struct.source));
+ if (typeof value === 'object') {
+ console.log(value);
+ if (value.require.includes(table.type)) {
+ $el.find('select').append(setValueAndName($(''), value.value, struct.source));
+ }
+ } else {
+ $el.find('select').append(setValueAndName($(''), value, struct.source));
+ }
}
$el.find('select').val(data);
return $el;
@@ -148,7 +170,11 @@ function generateSet(data, struct) {
let $el = $('#components').find('[data-type="set"]').clone();
$el.attr('data-field', struct.id);
$el.find('[data-name]').attr('data-i18n', struct.id);
- for (let value of struct.values) {
+ let collection = struct.values;
+ if (typeof struct.values === 'string') {
+ collection = collections[struct.values];
+ }
+ for (let value of collection) {
let $item = $('');
setValueAndName($item, value, struct.source);
$el.find('.dropdown-menu').append($item);
@@ -212,8 +238,14 @@ function generateNbt(data, struct) {
}
function generateError(error) {
+ let message = 'Unknown Error';
+ if (typeof error === 'object' && typeof error.message === 'string') {
+ message = error.message;
+ } else if (typeof error === 'string'){
+ message = error;
+ }
let $el = $('#components').find('[data-type="error"]').clone();
- $el.find('[data-name]').val(error);
+ $el.find('[data-name]').val(message);
return $el;
}