Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save TheSkorm/c957b87ce48fdb427a97 to your computer and use it in GitHub Desktop.

Select an option

Save TheSkorm/c957b87ce48fdb427a97 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type='text/javascript' src='/js/lib/dummy.js'></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
</style>
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
// HOWTO
// 1. change loaderid to something unique that hasn't been used on the server before
// 2. edit toload to be a set of coords you want loaded. only include the ones you want enity loaded, the rest will be loaded automatically
// build a hopper clock at spawn and connect up a command block for each command. ensure nothing is above the command block for 10
// 3. on a pulsed redstone signal setup a command block that "/testfor @e[name=LoaderIdGoesHere]" then connect that to a comparator and NAND that signal with a pulsed signal, and connect that to a command block that does " /summon Bat ~0 ~1 ~0 {CustomName:LoaderIdGoesHere,CustomNameVisible:1,ActiveEffects:[{Id:14,Amplifier:1,Duration:999999}],Invulnerable:1,PersistenceRequired:1}"
loaderid = "aLoader" // must be unique
toload = [
[-102313.0,-97979.6],
[-102313.0,-97800.6],
[-10233.0,-9779.6]
]
spawnloader(toload)
function spawnloader(coords){
// coords = list of blockid coords of the chunk that needs to be loaded. [[a,b],[c,d],...]
var chunkids = {}
// find chunk ids
for(var i=0; i<coords.length; i++){
for(var x=-2; x<3; x++){
for(var y=-2; y<3; y++){
chunkids[[Math.floor(coords[i][0]/16)+x,Math.floor(coords[i][1]/16)+y]] = [((Math.floor(coords[i][0]/16)+x)*16+8),((Math.floor(coords[i][1]/16)+y)*16+8)]
}
}
}
gen_commands(chunkids)
}
function gen_commands(chunkids){
var commandcount = 0;
var currentblockcommands = []
var loadercount = 0;
for (var key in chunkids) {
if (chunkids.hasOwnProperty(key)) {
loadercount++
currentblockcommands.push("spreadplayers " + chunkids[key][0] + " " + chunkids[key][1] + " 0 1 true @e[name=" + loaderid +(Math.floor(loadercount/25))+"]");
if(commandcount==7){
makecommandblock(currentblockcommands);
currentblockcommands = []
commandcount=0
} else {
commandcount++;
}
}
}
if (commandcount != 0){
makecommandblock(currentblockcommands);
}
document.getElementById("commands").innerHTML = document.getElementById("commands").innerHTML + "<br><br> Loaders needed " + Math.floor(loadercount/25)
}
function makecommandblock(commands){
var header = "summon MinecartCommandBlock ~ ~1 ~ {"
for(var i=0; i<commands.length; i++){
header = header + "Riding:{id:MinecartCommandBlock,"
}
header = header + "Riding:{id:FallingSand,TileID:157,Time:2}"
var footer = ",Command:setblock ~ ~ ~ lava 7}"
var body = "";
for(var i=0; i<commands.length; i++){
body = body + ",Command:\"" + commands[i] + "\"}"
}
document.getElementById("commands").innerHTML = document.getElementById("commands").innerHTML + "<br><br>" + header + body + footer
}
}//]]>
</script>
</head>
<body>
<div id="commands"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment