mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-07 07:51:46 +00:00
Add damage source properties
This commit is contained in:
@@ -246,7 +246,7 @@ function updateField(el) {
|
||||
let type = getType(el);
|
||||
let value = undefined;
|
||||
|
||||
if (type === 'string' || type === 'int' || type === 'float' || type === 'enum' || type === 'json' || type === 'nbt') {
|
||||
if (type === 'string' || type === 'int' || type === 'float' || type === 'enum' || type === 'json' || type === 'nbt' || type === 'chance-list') {
|
||||
value = $(el).val();
|
||||
}
|
||||
if (type === 'int') {
|
||||
@@ -259,7 +259,21 @@ function updateField(el) {
|
||||
if (isNaN(value)) {
|
||||
value = '';
|
||||
}
|
||||
} else if(type === 'enum') {
|
||||
} else if (type === 'chance-list') {
|
||||
value = '[' + value + ']';
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] > 1) {
|
||||
value[i] = 1;
|
||||
} else if (value[i] < 0) {
|
||||
value[i] = 0;
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
value = [];
|
||||
}
|
||||
} else if (type === 'enum') {
|
||||
if (value === 'unset') {
|
||||
value = '';
|
||||
}
|
||||
|
||||
+82
-1
@@ -423,7 +423,7 @@
|
||||
},
|
||||
{
|
||||
"id": "chances",
|
||||
"type": "list",
|
||||
"type": "chance-list",
|
||||
"require": [
|
||||
"minecraft:table_bonus"
|
||||
]
|
||||
@@ -466,6 +466,14 @@
|
||||
"minecraft:match_tool"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "predicate",
|
||||
"type": "object",
|
||||
"value": "damage_source",
|
||||
"require": [
|
||||
"minecraft:damage_source_properties"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "term",
|
||||
"type": "object",
|
||||
@@ -655,6 +663,79 @@
|
||||
"type": "nbt"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "damage_source",
|
||||
"type": "object",
|
||||
"color": "dark",
|
||||
"fields": [
|
||||
{
|
||||
"id": "dealt",
|
||||
"type": "range"
|
||||
},
|
||||
{
|
||||
"id": "taken",
|
||||
"type": "range"
|
||||
},
|
||||
{
|
||||
"id": "blocked",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "type",
|
||||
"type": "object",
|
||||
"color": "dark",
|
||||
"collapse": true,
|
||||
"fields": [
|
||||
{
|
||||
"id": "is_explosion",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "is_projectile",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "is_fire",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "is_lightning",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "is_magic",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "bypasses_magic",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "bypasses_invulnerability",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "bypasses_armor",
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "source_entity",
|
||||
"type": "object",
|
||||
"color": "dark",
|
||||
"collapse": true,
|
||||
"value": "entity"
|
||||
},
|
||||
{
|
||||
"id": "direct_entity",
|
||||
"type": "object",
|
||||
"color": "dark",
|
||||
"collapse": true,
|
||||
"value": "entity"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"collections": {
|
||||
|
||||
@@ -58,6 +58,7 @@ function generateComponent(data, struct) {
|
||||
case 'string': return generateString(data, struct);
|
||||
case 'int': return generateString(data, struct);
|
||||
case 'float': return generateString(data, struct);
|
||||
case 'chance-list': return generateString(data, struct);
|
||||
case 'boolean': return generateBoolean(data, struct);
|
||||
case 'random': return generateRandom(data, struct);
|
||||
case 'range': return generateRange(data, struct);
|
||||
@@ -76,6 +77,7 @@ function generateComponent(data, struct) {
|
||||
|
||||
function generateString(data, struct) {
|
||||
let $el = $('#components').find('[data-type="string"]').clone();
|
||||
$el.attr('data-type', struct.type);
|
||||
$el.attr('data-index', struct.id);
|
||||
$el.find('[data-name]').attr('data-i18n', struct.id);
|
||||
$el.find('input').val(data);
|
||||
@@ -282,7 +284,8 @@ function generateObject(data, struct, header) {
|
||||
if (field.collapse) {
|
||||
$body.append('<button type="button" class="btn btn-light mt-3 dropdown-toggle" onclick="toggleCollapseObject(this)" data-index="' + field.id + '" data-i18n="' + field.id + '"></button>');
|
||||
if (data[field.id] === undefined) {
|
||||
break;
|
||||
$body.append('<div/>');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user