JSFiddle - React, Tailwind, and code Playground
HTML
EntityID: <input type="text" size="20" id="entity" value="VillagerGolem"><br>
Stack height: <input type="number" size="5" id="height" value="100"><br>
<input type="button" id="button" value="Do it!"><br><br>
Output:<br>
<textarea cols="80" rows="8" id="output"></textarea>
JavaScript
$(document).ready(function() {
$("#button").click(function() {
var EntityId = $("#entity").val();
var stack = parseInt($("#height").val());
var $out = $("#output");
var result = "/setblock ~ ~1 ~ mob_spawner 0 replace {EntityId:"
+ EntityId + ", SpawnData:" + riding(EntityId, stack - 1, "first") + "}";
$out.val(result);
});
});
function riding(entity, count, first) {
var str = "{";
if (!first) {
str = "{id:" + entity;
}
if (count > 0) {
if (str.length > 1) {
str += ", ";
}
str += "Riding: " + riding(entity, count - 1);
}
str += "}";
return str;
}