{"id":938,"date":"2017-03-20T11:15:09","date_gmt":"2017-03-20T10:15:09","guid":{"rendered":"http:\/\/heppg.de\/ikg\/wordpress\/?p=938"},"modified":"2017-03-20T14:07:16","modified_gmt":"2017-03-20T13:07:16","slug":"minecraft-and-scratchclient","status":"publish","type":"post","link":"https:\/\/heppg.de\/ikg\/wordpress\/?p=938","title":{"rendered":"minecraft and scratchClient"},"content":{"rendered":"<p>On raspberry pi, there is a local minecraft release available which supports a python API.<\/p>\n<p>There is a MinecraftAdapter available for scratchClient which supports this API and allows to do basic operations.<\/p>\n<p>For most of the operations, there are coordinate values to be set first before the operation is performed.<\/p>\n<p>Example: set position of &#8216;person&#8217;.<\/p>\n<p><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setPos.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-939 size-full\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setPos.png\" alt=\"\" width=\"433\" height=\"90\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setPos.png 433w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setPos-300x62.png 300w\" sizes=\"auto, (max-width: 433px) 100vw, 433px\" \/><\/a><\/p>\n<p>Example: set Block<\/p>\n<p><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setBlock.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-940 size-full\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setBlock.png\" alt=\"\" width=\"433\" height=\"138\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setBlock.png 433w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/setBlock-300x96.png 300w\" sizes=\"auto, (max-width: 433px) 100vw, 433px\" \/><\/a><\/p>\n<p>There is a sample scratch application in scratch\/minecraft\/minecraft.sb which demonstrates the basic concepts.<\/p>\n<p>There are some demo scripts in minecraft.sb. One of these writes &#8216;scratch&#8217; to the landscape. There is no &#8216;printString&#8217;-Function in the adapter. The pixel are defined in a local list, containing x and y-values of pixels. The data for this array are generated by a small python script and then imported into the list.<\/p>\n<p><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/minecraft_scratch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-941\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/minecraft_scratch-300x170.png\" alt=\"\" width=\"300\" height=\"170\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/minecraft_scratch-300x170.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/minecraft_scratch-768x435.png 768w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/minecraft_scratch-624x353.png 624w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2017\/03\/minecraft_scratch.png 846w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The python code is in scratch\/minecraft\/scratch_x_y.py. Run it by<\/p>\n<pre>python scratch_x_y.py &gt; scratch_x_y.txt<\/pre>\n<p>and import the txt-file into the array.<\/p>\n<p>The python code is quite simple.<\/p>\n<pre>f0=\"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>*<\/strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"\u00a0\u00a0 \u00a0\r\nf1=\"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"\r\nf2=\" ***\u00a0\u00a0 ***\u00a0 * **\u00a0\u00a0 ***\u00a0 ***\u00a0\u00a0\u00a0 ***\u00a0 * **\u00a0\u00a0\u00a0\u00a0 \"\r\nf3=\"*\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 * **\u00a0 *\u00a0\u00a0\u00a0\u00a0 *\u00a0 *\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0 **\u00a0 *\u00a0\u00a0\u00a0 \"\r\nf4=\" ***\u00a0 *\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0 ****\u00a0 *\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 *\u00a0\u00a0\u00a0 \"\r\nf5=\"\u00a0\u00a0\u00a0 * *\u00a0\u00a0 * *\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 *\u00a0 *\u00a0 * *\u00a0\u00a0 * *\u00a0\u00a0 *\u00a0\u00a0\u00a0 \"\r\nf6=\"****\u00a0\u00a0 ***\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0 ****\u00a0\u00a0 **\u00a0\u00a0 ***\u00a0 *\u00a0\u00a0 *\u00a0\u00a0\u00a0 \"\r\n\r\ndef printPixel(f, level):\r\n\u00a0\u00a0\u00a0 for i in range(len(f)):\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if '*' == f[i]:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print(i)      # print x-koordinate\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print(level)  # print y-koordinate\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\nprintPixel(f6, 1)\r\nprintPixel(f5, 2)\r\nprintPixel(f4, 3)\r\nprintPixel(f3, 4)\r\nprintPixel(f2, 5)\r\nprintPixel(f1, 6)\r\nprintPixel(f0, 7)<\/pre>\n<p>The pixels are defined in &#8216;pseudographic&#8217;. It is simple to add more text, decorations or extend the output by colors ( * ==&gt; green, # ==&gt; red) and adjust the scratch script to take each third line for the color information.<br \/>\nBut keep in mind that &#8216;the world&#8217; is limited size for minecraft for py and coordinates should be kept in range.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On raspberry pi, there is a local minecraft release available which supports a python API. There is a MinecraftAdapter available for scratchClient which supports this API and allows to do basic operations. For most of the operations, there are coordinate values to be set first before the operation is performed. Example: set position of &#8216;person&#8217;. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-938","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=938"}],"version-history":[{"count":4,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/938\/revisions"}],"predecessor-version":[{"id":945,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/938\/revisions\/945"}],"wp:attachment":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}