Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active June 15, 2018 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/3160b5c2e47687f70d6ccc07e1321343 to your computer and use it in GitHub Desktop.
Save kenwebb/3160b5c2e47687f70d6ccc07e1321343 to your computer and use it in GitHub Desktop.
Minecraft - JavaScript Data and Assets
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Fri Jun 15 2018 07:20:24 GMT-0400 (Eastern Daylight Time)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Minecraft - JavaScript Data and Assets
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: 3160b5c2e47687f70d6ccc07e1321343
Keywords:
My Notes
--------
June 12, 2018
My minecraft version is 1.12.2
I downlaoded several github projects to ~/JavascriptThirdParty/minecraft
~/JavascriptThirdParty/minecraft/minecraft-assets-master/data/1.12/ [4]
texture_content.json
"name":"iron_shovel",
"texture":"data:image/png;base64,....."
blocks_textures.json
items_textures.json
blocks
.png are 16 x 16 pixels
.mcmeta are animation rules/params; text files
items
.png
To locate a specific block from Dev Tools:
--------------------------
xh.root().first().xpath("Blocks/Block[@roleName='Bedrock']");
To list all blocks with their id and displayName:
------------------
var root = xh.root();
var blocks = root.first().xpath("Blocks");
var block = blocks.first();
while (block) {
root.println("" + block.json.id + "\t" + block.role());
block = block.next();
}
To diplay TextureContents d3cp:
------------------------------
$wnd.xh.xport("_d3,CirclePack", $wnd.xh.root().first().xpath("TextureContents"), '{"shouldShowStateMachineEntities":false,"shouldIncludeDecorations":true,"sort":"default","filter":"--Behavior,Script","width":800,"height":800,"selection":"#xhgraph","mode":"new","labelContainers":true,"labelContainersOptions":"top","includeId":true,"includeClass":true,"shape":"circle","shapeParams":"5,5","maxSvg":50,"useIcons":true,"iconPos":"outside","useSymbols":false,"useAnno":false,"annoPos":"outside","maxChars":1,"fontSizeMultiplier":1.75,"marble":"","supportTouch":false,"_jsdata":false,"nonportPorts":false}');
References
----------
(1) https://github.com/PrismarineJS/
NodeJS game server compatible with the Minecraft Client.
(2) https://github.com/PrismarineJS/minecraft-data
Language independent module providing minecraft data for minecraft clients, servers and libraries.
(3) http://minecraft-data.prismarine.js.org/
1.12.2
Biomes
Instruments
Items
Materials
Blocks
Recipes
Entities
Protocol
Windows
Effects
(4) https://github.com/rom1504/minecraft-assets
Provide minecraft assets along with json files that help to use them.
Romain Beaumont
(5) https://www.npmjs.com/~rom1504
]]></Notes>
<_-.XholonClass>
<PhysicalSystem/>
<Biome/>
<Block/>
<Effect/>
<Entity/>
<Instrument/>
<Items/>
<Material/>
<Recipe>
<ShapedRecipe/> <!-- contains: result, inShape, optional outShape -->
<ShapelessRecipe/> <!-- contains: result, ingredients -->
</Recipe>
<Version/>
<Window/>
<!-- Recipe contents -->
<Result/>
<InShape/>
<OutShape/>
<Ingredients/>
<Biomes/>
<Blocks/>
<Effects/>
<Entities/>
<Instruments/>
<Item/>
<Materials/>
<Recipes/>
<Versions/>
<Windows/>
<!-- texture_content.json -->
<TextureContent/>
<TextureContents/>
</_-.XholonClass>
<xholonClassDetails>
</xholonClassDetails>
<PhysicalSystem>
<!-- Biomes
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/biomes.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=biomes
biomes
array biome
id integer [0;∞] The unique identifier for a biome
color integer [0;∞] The color in a biome
name string /\S+/ The name of a biome
rainfall number [0;1] How much rain there is in a biome
temperature number [-1;2] An indicator for the temperature in a biome
-->
<Biomes><Attribute_String><![CDATA[
[
{
"id": 0,
"color": 112,
"name": "Ocean",
"rainfall": 0.5,
"temperature": 0.5
},
{
"id": 1,
"color": 9286496,
"name": "Plains",
"rainfall": 0.4,
"temperature": 0.8
},
{
"id": 2,
"color": 16421912,
"name": "Desert",
"rainfall": 0,
"temperature": 2
},
{
"id": 3,
"color": 6316128,
"name": "Extreme Hills",
"rainfall": 0.3,
"temperature": 0.2
},
{
"id": 4,
"color": 353825,
"name": "Forest",
"rainfall": 0.8,
"temperature": 0.7
},
{
"id": 5,
"color": 747097,
"name": "Taiga",
"rainfall": 0.8,
"temperature": 0.05
},
{
"id": 6,
"color": 522674,
"name": "Swampland",
"rainfall": 0.9,
"temperature": 0.8
},
{
"id": 7,
"color": 255,
"name": "River",
"rainfall": 0.5,
"temperature": 0.5
},
{
"id": 8,
"color": 16711680,
"name": "Hell",
"rainfall": 0,
"temperature": 2
},
{
"id": 9,
"color": 8421631,
"name": "The End",
"rainfall": 0.5,
"temperature": 0.5
},
{
"id": 10,
"color": 9474208,
"name": "FrozenOcean",
"rainfall": 0.5,
"temperature": 0
},
{
"id": 11,
"color": 10526975,
"name": "FrozenRiver",
"rainfall": 0.5,
"temperature": 0
},
{
"id": 12,
"color": 16777215,
"name": "Ice Plains",
"rainfall": 0.5,
"temperature": 0
},
{
"id": 13,
"color": 10526880,
"name": "Ice Mountains",
"rainfall": 0.5,
"temperature": 0
},
{
"id": 14,
"color": 16711935,
"name": "MushroomIsland",
"rainfall": 1,
"temperature": 0.9
},
{
"id": 15,
"color": 10486015,
"name": "MushroomIslandShore",
"rainfall": 1,
"temperature": 0.9
},
{
"id": 16,
"color": 16440917,
"name": "Beach",
"rainfall": 0.4,
"temperature": 0.8
},
{
"id": 17,
"color": 13786898,
"name": "DesertHills",
"rainfall": 0,
"temperature": 2
},
{
"id": 18,
"color": 2250012,
"name": "ForestHills",
"rainfall": 0.8,
"temperature": 0.7
},
{
"id": 19,
"color": 1456435,
"name": "TaigaHills",
"rainfall": 0.7,
"temperature": 0.2
},
{
"id": 20,
"color": 7501978,
"name": "Extreme Hills Edge",
"rainfall": 0.3,
"temperature": 0.2
},
{
"id": 21,
"color": 5470985,
"name": "Jungle",
"rainfall": 0.9,
"temperature": 1.2
},
{
"id": 22,
"color": 2900485,
"name": "JungleHills",
"rainfall": 0.9,
"temperature": 1.2
},
{
"id": 23,
"color": 6458135,
"name": "JungleEdge",
"rainfall": 0.8,
"temperature": 0.95
},
{
"id": 24,
"color": 48,
"name": "Deep Ocean",
"rainfall": 0.5,
"temperature": 0.5
},
{
"id": 25,
"color": 10658436,
"name": "Stone Beach",
"rainfall": 0.3,
"temperature": 0.2
},
{
"id": 26,
"color": 16445632,
"name": "Cold Beach",
"rainfall": 0.3,
"temperature": 0.05
},
{
"id": 27,
"color": 3175492,
"name": "Birch Forest",
"rainfall": 0.6,
"temperature": 0.6
},
{
"id": 28,
"color": 2055986,
"name": "Birch Forest Hills",
"rainfall": 0.6,
"temperature": 0.6
},
{
"id": 29,
"color": 4215066,
"name": "Roofed Forest",
"rainfall": 0.8,
"temperature": 0.7
},
{
"id": 30,
"color": 3233098,
"name": "Cold Taiga",
"rainfall": 0.4,
"temperature": -0.5
},
{
"id": 31,
"color": 2375478,
"name": "Cold Taiga Hills",
"rainfall": 0.4,
"temperature": -0.5
},
{
"id": 32,
"color": 5858897,
"name": "Mega Taiga",
"rainfall": 0.8,
"temperature": 0.3
},
{
"id": 33,
"color": 4542270,
"name": "Mega Taiga Hills",
"rainfall": 0.8,
"temperature": 0.3
},
{
"id": 34,
"color": 5271632,
"name": "Extreme Hills+",
"rainfall": 0.3,
"temperature": 0.2
},
{
"id": 35,
"color": 12431967,
"name": "Savanna",
"rainfall": 0,
"temperature": 1.2
},
{
"id": 36,
"color": 10984804,
"name": "Savanna Plateau",
"rainfall": 0,
"temperature": 1
},
{
"id": 37,
"color": 14238997,
"name": "Mesa",
"rainfall": 0.5,
"temperature": 2.0
},
{
"id": 38,
"color": 11573093,
"name": "Mesa Plateau F",
"rainfall": 0.5,
"temperature": 2.0
},
{
"id": 39,
"color": 13274213,
"name": "Redwood Taiga Hills M",
"rainfall": 0.5,
"temperature": 2.0
}
]
]]></Attribute_String></Biomes>
<!-- Blocks
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/blocks.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=blocks
blocks array block
id integer [0;∞] The unique identifier for a block
displayName string The display name of a block
name string /\S+/ The name of a block
hardness number,null [0;∞] Hardness of a block
stackSize integer [0;∞] Stack size for a block
diggable boolean true if a block is diggable
boundingBoxenum block empty BoundingBox of a block
material string Material of a block
harvestTools Using one of these tools is required to harvest a block, without that you get a 3.33x time penalty.
variations array
drops array
transparent boolean true if a block is transparent
emitLight integer [0;15] Light emitted by that block
filterLight integer [0;15] Light filtered by that block
start and end of JSON content:
[
{
"id": 0,
"displayName": "Air",
"name": "air",
"hardness": 0,
"stackSize": 0,
"diggable": true,
"boundingBox": "empty",
"drops": [
{
"drop": 0
}
],
"transparent": true,
"emitLight": 0,
"filterLight": 0
},
...
{
"id": 255,
"displayName": "Structure Block",
"name": "structure_block",
"hardness": null,
"stackSize": 64,
"diggable": false,
"boundingBox": "block",
"variations": [
{
"metadata": 0,
"displayName": "Save"
},
{
"metadata": 1,
"displayName": "Load"
},
{
"metadata": 2,
"displayName": "Corner"
},
{
"metadata": 3,
"displayName": "Data"
}
],
"drops": [],
"transparent": false,
"emitLight": 0,
"filterLight": 15
}
]
-->
<Blocks/>
<!-- Effects
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/effects.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=effects
effects array effect
id integer [0;∞] The unique identifier for an effect
displayName string The display name of an effect
name string /\S+/ The name of an effect
type enum good bad Whether an effect is positive or negative
start and end of JSON content:
[
{
"id": 1,
"name": "Speed",
"displayName": "Speed",
"type": "good"
},
...
{
"id": 27,
"name": "BadLuck",
"displayName": "Bad Luck",
"type": "bad"
}
]
-->
<Effects/>
<!-- Entities
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/entities.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=entities
entities array entity
id integer [0;∞] The unique identifier for an entity
internalId integer [0;∞] The internal id of an entity : used in eggs metadata for example
displayName string The display name of an entity
name string /\S+/ The name of an entity
type string The type of an entity
width number,null The width of the entity
height number,null The height of the entity
category string The category of an entity : a semantic category
start and end of JSON content:
[
{
"id": 1,
"internalId": 1,
"name": "item",
"displayName": "Dropped item",
"type": "mob",
"width": 0.25,
"height": 0.25,
"category": "Drops"
},
...
{
"id": 93,
"internalId": 26,
"name": "dragon_fireball",
"displayName": "Dragon fireball",
"type": "object",
"width": 1,
"height": 1,
"category": "Projectiles"
}
]
-->
<Entities/>
<!-- Instruments
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/instruments.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=instruments
instruments array instrument
id integer [0;∞] The unique identifier for an instrument
name string /\S+/ The name of an instrument
-->
<Instruments><Attribute_String><![CDATA[
[
{
"id": 0,
"name": "harp"
},
{
"id": 1,
"name": "doubleBass"
},
{
"id": 2,
"name": "snareDrum"
},
{
"id": 3,
"name": "sticks"
},
{
"id": 4,
"name": "bassDrum"
}
]
]]></Attribute_String></Instruments>
<!-- Items
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/items.json
items array item
id integer [0;∞] The unique identifier for an item
displayName string The display name of an item
stackSize integer [0;∞] Stack size for an item
name string /\S+/ The name of an item
variations array
start and end of JSON content:
[
{
"id": 256,
"displayName": "Iron Shovel",
"stackSize": 1,
"name": "iron_shovel"
},
...
{
"id": 2267,
"displayName": "Wait Disc",
"stackSize": 1,
"name": "record_wait"
}
]
-->
<Items/>
<!-- Materials
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=materials
start and end of JSON content:
{
"rock": {
"257": 6,
"270": 2,
"274": 4,
"278": 8,
"285": 12
},
...
"wool": {
"359": 4.8
}
}
-->
<Materials/>
<!-- Recipes
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/recipes.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=recipes
TODO this text is incomplete
recipes A dictionary of quoted numerical item IDs. Each ID maps to a list of recipes. There may be multiple different recipes per item (same ID and metadata). The recipes may not be sorted.
^[0-9]+$ array recipe
recipe one of: shaped recipe, shapeless recipe
shaped recipe A shaped recipe is a dictionary of result, inShape and optionally outShape
result: recipe item An item can be represented different ways.
one of: ...
inShape shape A shape is a list of rows, which are lists of items. There must be at least one row with at least one item in it. All rows must have the same length. Empty rows at the beginning or end of a shape may be omitted. Empty colums at the end may also be omitted. When an item can be crafted in a 2x2 grid, the shape may not be larger than 2x2.
array[1..3]
shapeRow
array[1..3]
recipe item
An item can be represented different ways.
one of:
outShape
-->
<Recipes/>
<!-- Versions
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/version.json
-->
<Versions><Attribute_String><![CDATA[
{
"minecraftVersion": "1.12",
"version":335,
"majorVersion": "1.12"
}
]]></Attribute_String></Versions>
<!-- Windows
~/JavascriptThirdParty/minecraft/minecraft-data-master/data/pc/1.12/windows.json
http://minecraft-data.prismarine.js.org/?v=1.12.2&d=windows
windows array[1..] window
id string The unique identifier for the window
name string The default displayed name of the window
slots array[1..] The slots displayed in the window
properties array[1..] string Names of the properties of the window
openedWith array object
-->
<Windows/>
<!-- Texture Content
https://github.com/rom1504/minecraft-assets/tree/master/data/1.12
-->
<TextureContents/>
</PhysicalSystem>
<Biomesbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode.parent();
me.println("Doing Biomes ...");
var jsonStr = me.first().text();
me.first().remove(); // remove the Attribute_String node
var json = $wnd.JSON.parse(jsonStr);
// create Biome nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["name"];
var xmlStr = '<Biome roleName="' + rname + '"></Biome>';
me.append(xmlStr);
me.last()["json"] = obj;
}
this.cnode.remove();
}
}
//# sourceURL=Biomesbehavior.js
]]></Biomesbehavior>
<Instrumentsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode.parent();
me.println("Doing Instruments ...");
var jsonStr = me.first().text();
me.first().remove(); // remove the Attribute_String node
var json = $wnd.JSON.parse(jsonStr);
// create Instrument nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["name"];
var xmlStr = '<Instrument roleName="' + rname + '"></Instrument>';
me.append(xmlStr);
me.last()["json"] = obj;
}
this.cnode.remove();
}
}
//# sourceURL=Instrumentsbehavior.js
]]></Instrumentsbehavior>
<Versionsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode.parent();
me.println("Doing Version ...");
var jsonStr = me.first().text();
me.first().remove(); // remove the Attribute_String node
var json = $wnd.JSON.parse(jsonStr);
// create single Version node
var rname = json["minecraftVersion"];
var xmlStr = '<Version roleName="' + rname + '"></Version>';
me.append(xmlStr);
me.last()["json"] = json;
this.cnode.remove();
}
}
//# sourceURL=Versionsbehavior.js
]]></Versionsbehavior>
<Materialsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Material nodes, each pointing to part of the json
for (var prop in json) {
var obj = json[prop];
var rname = prop;
var xmlStr = '<Material roleName="' + rname + '"></Material>';
me.append(xmlStr);
me.last()["json"] = obj;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/materials.json");
oReq.send();
me.println("Getting materials.json ...");
}
}
//# sourceURL=Materialsbehavior.js
]]></Materialsbehavior>
<Itemsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Item nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["displayName"];
var xmlStr = '<Item roleName="' + rname + '"></Item>';
me.append(xmlStr);
me.last()["json"] = obj;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/items.json");
oReq.send();
me.println("Getting items.json ...");
}
}
//# sourceURL=Itemsbehavior.js
]]></Itemsbehavior>
<Blocksbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Block nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["displayName"];
var xmlStr = '<Block roleName="' + rname + '"></Block>';
me.append(xmlStr);
me.last()["json"] = obj;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/blocks.json");
oReq.send();
me.println("Getting blocks.json ...");
}
}
//# sourceURL=Blocksbehavior.js
]]></Blocksbehavior>
<Windowsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Window nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["name"];
var xmlStr = '<Window roleName="' + rname + '"></Window>';
me.append(xmlStr);
me.last()["json"] = obj;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/windows.json");
oReq.send();
me.println("Getting windows.json ...");
}
}
//# sourceURL=Windowsbehavior.js
]]></Windowsbehavior>
<Effectsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Effect nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["displayName"];
var xmlStr = '<Effect roleName="' + rname + '"></Effect>';
me.append(xmlStr);
me.last()["json"] = obj;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/effects.json");
oReq.send();
me.println("Getting effects.json ...");
}
}
//# sourceURL=Effectsbehavior.js
]]></Effectsbehavior>
<Entitiesbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Entity nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["displayName"];
var xmlStr = '<Entity roleName="' + rname + '"></Entity>';
me.append(xmlStr);
me.last()["json"] = obj;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/entities.json");
oReq.send();
me.println("Getting entities.json ...");
}
}
//# sourceURL=Entitiesbehavior.js
]]></Entitiesbehavior>
<Recipesbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create Recipe nodes, each pointing to part of the json
for (var prop in json) {
var arr = json[prop]; // arr is an array of objects
var rname = prop;
var xmlStr = '<Recipe roleName="' + rname + '">';
for (var i = 0; i < arr.length; i++) {
var obj = arr[i];
if (obj["inShape"]) {
xmlStr += '<ShapedRecipe roleName="' + 'D' + '"><Anno>';
var inshArr = obj["inShape"]; // an array of arrays of numbers and/or an array of arrays of objects
var writeSep = false; // whether or not to write out a separator ","
for (var jout = 0; jout < inshArr.length; jout++) {
var inshArr2 = inshArr[jout];
for (var j = 0; j < inshArr2.length; j++) {
if (writeSep) {xmlStr += ",";} else {writeSep = true;}
var insh = inshArr2[j];
if (insh == null) {
$wnd.console.log("insh is null");
}
else if (typeof insh == "object") {
xmlStr += insh["id"];
}
else if (typeof insh == "number") {
xmlStr += insh;
}
else {
$wnd.console.log("Unknown inShape type " + typeof insh);
}
}
}
xmlStr += ' > ' + rname + '*' + obj["result"]["count"] + '</Anno></ShapedRecipe>';
}
else { // "ingredients"
xmlStr += '<ShapelessRecipe roleName="' + 'L' + '"><Anno>';
var ingrArr = obj["ingredients"]; // an array of numbers and/or objects
for (var k = 0; k < ingrArr.length; k++) {
if (k > 0) {xmlStr += ",";}
var ingr = ingrArr[k];
if (typeof ingr == "object") {
xmlStr += ingr["id"];
}
else if (typeof ingr == "number") {
xmlStr += ingr;
}
else {
$wnd.console.log("Unknown ingredient type " + typeof ingr);
}
}
xmlStr += ' > ' + rname + '*' + obj["result"]["count"] + '</Anno></ShapelessRecipe>';
}
}
xmlStr += '</Recipe' + '>';
me.append(xmlStr);
me.last()["json"] = arr;
}
beh.cnode.remove();
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/data/1.12/recipes.json");
oReq.send();
me.println("Getting recipes.json ...");
}
}
//# sourceURL=Recipesbehavior.js
]]></Recipesbehavior>
<TextureContentsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
function reqListener () {
var jsonStr = this.responseText;
var json = $wnd.JSON.parse(jsonStr);
// create texture_content nodes, each pointing to part of the json
for (var i = 0; i < json.length; i++) {
var obj = json[i];
var rname = obj["name"];
var xmlStr = '<TextureContent roleName="' + rname + '">';
if (obj["texture"]) {
xmlStr += '<Icon>' + obj["texture"] + '</Icon>';
}
xmlStr += '</' + 'TextureContent>';
me.append(xmlStr);
}
beh.cnode.remove();
$wnd.xh.xport("_d3,CirclePack", $wnd.xh.root().first().xpath("TextureContents"), '{"shouldShowStateMachineEntities":false,"shouldIncludeDecorations":true,"sort":"default","filter":"--Behavior,Script","width":800,"height":800,"selection":"#xhgraph","mode":"new","labelContainers":true,"labelContainersOptions":"top","includeId":true,"includeClass":true,"shape":"circle","shapeParams":"5,5","maxSvg":50,"useIcons":true,"iconPos":"inside","useSymbols":false,"useAnno":false,"annoPos":"outside","maxChars":1,"fontSizeMultiplier":1.75,"marble":"","supportTouch":false,"_jsdata":false,"nonportPorts":false}');
}
var me, oReq, beh = {
postConfigure: function() {
me = this.cnode.parent();
oReq = new $wnd.XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://127.0.0.1:8888/minecraft/assets/1.12/texture_content.json");
oReq.send();
me.println("Getting texture_content.json ...");
}
}
//# sourceURL=TextureContentsbehavior.js
]]></TextureContentsbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Biomes</title>
<rect id="PhysicalSystem/Biomes" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>Biome</title>
<rect id="PhysicalSystem/Biomes/Biome" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment