mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-02 21:52:54 +00:00
Be more flexible when minecraft: is not given + random -> range in 1.13
This commit is contained in:
@@ -113,6 +113,7 @@
|
|||||||
"$function": {
|
"$function": {
|
||||||
"$type": {
|
"$type": {
|
||||||
"set_count": "Set Count",
|
"set_count": "Set Count",
|
||||||
|
"set_data": "Set Data",
|
||||||
"set_damage": "Set Damage",
|
"set_damage": "Set Damage",
|
||||||
"set_name": "Set Name",
|
"set_name": "Set Name",
|
||||||
"set_lore": "Set Lore",
|
"set_lore": "Set Lore",
|
||||||
|
|||||||
+4
-4
@@ -70,12 +70,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "weight",
|
"id": "weight",
|
||||||
"type": "random",
|
"type": "range",
|
||||||
"translate": "$entry.weight"
|
"translate": "$entry.weight"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "quality",
|
"id": "quality",
|
||||||
"type": "random",
|
"type": "range",
|
||||||
"translate": "$entry.quality",
|
"translate": "$entry.quality",
|
||||||
"luckBased": true
|
"luckBased": true
|
||||||
},
|
},
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "damage",
|
"id": "damage",
|
||||||
"type": "random",
|
"type": "range",
|
||||||
"translate": "$function.damage",
|
"translate": "$function.damage",
|
||||||
"require": [
|
"require": [
|
||||||
"minecraft:set_damage"
|
"minecraft:set_damage"
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "levels",
|
"id": "levels",
|
||||||
"type": "random",
|
"type": "range",
|
||||||
"translate": "$function.levels",
|
"translate": "$function.levels",
|
||||||
"require": [
|
"require": [
|
||||||
"minecraft:enchant_with_levels"
|
"minecraft:enchant_with_levels"
|
||||||
|
|||||||
@@ -42,14 +42,11 @@ function generateTable() {
|
|||||||
let type = structure.fields.find(e => e.id === 'type');
|
let type = structure.fields.find(e => e.id === 'type');
|
||||||
if (type) {
|
if (type) {
|
||||||
$('.table-type').removeClass('d-none');
|
$('.table-type').removeClass('d-none');
|
||||||
if (!table.type) {
|
|
||||||
table.type = type.default;
|
|
||||||
}
|
|
||||||
$('#tableType').html('');
|
$('#tableType').html('');
|
||||||
for (let option of type.values) {
|
for (let option of type.values) {
|
||||||
$('#tableType').append(setValueAndName($('<option/>'), option, type.translateValue));
|
$('#tableType').append(setValueAndName($('<option/>'), option, type.translateValue));
|
||||||
}
|
}
|
||||||
$('#tableType').val(table.type);
|
$('#tableType').val(table.type ? correctNamespace(table.type) : type.default);
|
||||||
} else {
|
} else {
|
||||||
delete table.type;
|
delete table.type;
|
||||||
$('.table-type').addClass('d-none');
|
$('.table-type').addClass('d-none');
|
||||||
@@ -113,7 +110,7 @@ function generateRandom(data, struct) {
|
|||||||
$el.attr('data-index', struct.id);
|
$el.attr('data-index', struct.id);
|
||||||
$el.find('[data-name]').attr('data-i18n', struct.translate);
|
$el.find('[data-name]').attr('data-i18n', struct.translate);
|
||||||
if (typeof data === 'object') {
|
if (typeof data === 'object') {
|
||||||
if (data.type && data.type.match(/(minecraft:)?binomial/)) {
|
if (data.type && correctNamespace(data.type) === 'minecraft:binomial') {
|
||||||
$el.find('.binomial').removeClass('d-none');
|
$el.find('.binomial').removeClass('d-none');
|
||||||
$el.find('.binomial.n').val(data.n);
|
$el.find('.binomial.n').val(data.n);
|
||||||
$el.find('.binomial.p').val(data.p);
|
$el.find('.binomial.p').val(data.p);
|
||||||
@@ -168,14 +165,14 @@ function generateEnum(data, struct) {
|
|||||||
}
|
}
|
||||||
for (let value of collection) {
|
for (let value of collection) {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
if (value.require.includes(table.type)) {
|
if (value.require.includes(correctNamespace(table.type))) {
|
||||||
$el.find('select').append(setValueAndName($('<option/>'), value.value, struct.translateValue));
|
$el.find('select').append(setValueAndName($('<option/>'), correctNamespace(value.value), struct.translateValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$el.find('select').append(setValueAndName($('<option/>'), value, struct.translateValue));
|
$el.find('select').append(setValueAndName($('<option/>'), correctNamespace(value), struct.translateValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$el.find('select').val(data);
|
$el.find('select').val(correctNamespace(data));
|
||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +193,7 @@ function generateSet(data, struct) {
|
|||||||
let $setContainer = $('<div/>');
|
let $setContainer = $('<div/>');
|
||||||
for (let option of data) {
|
for (let option of data) {
|
||||||
let $item = $('<button type="button" onclick="removeFromSet(this, \'' + struct.id + '\')" />').addClass('btn btn-outline-danger bg-light btn-sm mr-2 mt-2');
|
let $item = $('<button type="button" onclick="removeFromSet(this, \'' + struct.id + '\')" />').addClass('btn btn-outline-danger bg-light btn-sm mr-2 mt-2');
|
||||||
setValueAndName($item, option, struct.translateValue);
|
setValueAndName($item, correctNamespace(option), struct.translateValue);
|
||||||
$setContainer.append($item);
|
$setContainer.append($item);
|
||||||
}
|
}
|
||||||
$el.append($setContainer);
|
$el.append($setContainer);
|
||||||
@@ -238,6 +235,11 @@ function setValueAndName($el, value, source) {
|
|||||||
return $el.attr('value', value).attr('data-i18n', name);
|
return $el.attr('value', value).attr('data-i18n', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function correctNamespace(s) {
|
||||||
|
if (typeof s === 'string' && !s.includes(':')) return 'minecraft:' + s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
function generateJson(data, struct) {
|
function generateJson(data, struct) {
|
||||||
let $el = $('#components').find('[data-type="json"]').clone();
|
let $el = $('#components').find('[data-type="json"]').clone();
|
||||||
$el.attr('data-index', struct.id);
|
$el.attr('data-index', struct.id);
|
||||||
@@ -369,14 +371,14 @@ function generateField(data, field, parent) {
|
|||||||
let filter = parent.fields.find(e => e.type === 'enum');
|
let filter = parent.fields.find(e => e.type === 'enum');
|
||||||
for (let requirement of field.require) {
|
for (let requirement of field.require) {
|
||||||
if (typeof requirement === 'string') {
|
if (typeof requirement === 'string') {
|
||||||
if (requirement === data[filter.id]) {
|
if (requirement === correctNamespace(data[filter.id])) {
|
||||||
passing = true;
|
passing = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let match = true;
|
let match = true;
|
||||||
for (let id in requirement) {
|
for (let id in requirement) {
|
||||||
if (requirement.hasOwnProperty(id)) {
|
if (requirement.hasOwnProperty(id)) {
|
||||||
if (requirement[id] !== data[parent.fields.find(e => e.id === id).id]) {
|
if (requirement[id] !== correctNamespace(data[parent.fields.find(e => e.id === id).id])) {
|
||||||
match = false;
|
match = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user