Вот вам два кода на генерацию
1.под землёй var pos = []; var ID = [89, 20, 5]; var rez = 5;
function newLevel(){ GEN.setText("Start generation"); GEN.setPosition(0); GEN.setStart(3); }
var GEN = { setStart:function(to){ GEN.setTick(to); }, setPosition:function(eff){ for(var dn = 0; dn < 100; dn++){ if(getTile(Math.floor(Player.getX()), Player.getY()-dn, Math.floor(Player.getZ()))==7){ eff +=1; pos = [Math.floor(Player.getX()), Player.getY()-dn + (eff - 1), Math.floor(Player.getZ())]; }} GEN.setText(eff-1); }, setBlock:function(sX, sY, sZ, id, data){ if(!data){ data = 0; } setTile(sX, sY, sZ, id, data); }, setBuild:function(ch){ for(var a = 0; a < ch; a++){ GEN.setBlock(pos[0], pos[1]+GEN.setRnd(5, 20), pos[2]+GEN.setRnd(5, 30), ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0], pos[1]+GEN.setRnd(5, 20), pos[2]+GEN.setRnd(-5, -30), ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0]+GEN.setRnd(5, 30), pos[1]+GEN.setRnd(5, 20), pos[2], ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0]+GEN.setRnd(-5, -30), pos[1]+GEN.setRnd(5, 20), pos[2], ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0]+GEN.setRnd(5, 30), pos[1]+GEN.setRnd(5, 20), pos[2]+GEN.setRnd(5, 30), ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0]+GEN.setRnd(-5, -30), pos[1]+GEN.setRnd(5, 20), pos[2]+GEN.setRnd(-5, -30), ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0]+GEN.setRnd(5, 30), pos[1]+GEN.setRnd(5, 20), pos[2]+GEN.setRnd(-5, -30), ID[Math.floor(Math.random()*ID.length)]); GEN.setBlock(pos[0]+GEN.setRnd(-5, -30), pos[1]+GEN.setRnd(5, 20), pos[2]+GEN.setRnd(5, 30), ID[Math.floor(Math.random()*ID.length)]); } }, setTick:function(tick){ var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); tick = tick * 1000; ctx.runOnUiThread(new java.lang.Runnable({run:function(){ try{ new android.os.Handler().postDelayed(new java.lang.Runnable({run:function(){ GEN.setTick(30); GEN.setPosition(0); GEN.setBuild(rez); GEN.setText("In: "+rez); } }),tick); } catch(err){ print("Error: "+err) } }})); }, setRnd:function(min, max){ return Math.floor((Math.random() * max) + min); }, setText:function(t){ clientMessage(ChatColor.WHITE+"["+ChatColor.RED+"GEN"+ChatColor.WHITE+"] "+ChatColor.WHITE+""+t); }, }
2.вот вам на поверхности
var ready=false; function newLevel(){ ready=false; } function leaveGame(){ ready=false; } function modTick(){ var cx=Math.round(Player.getX()/16); var cz=Math.round(Player.getZ()/16); if(!ready && Level.getTile(parseInt(Player.getX()),parseInt(Player.getY())-2,parseInt(Player.getZ()))!=0) ready=true; if(ready){ if(Math.floor(Math.random()*100)==10){ var rnd=Math.floor(Math.random()*6)+1; var x,y=0; if(rnd<4) x=3; else x=-3 rnd=Math.floor(Math.random()*6)+1; if(rnd<4) z=3; else z=-3 if(Level.getTile((cx+x)*16,1,(cz+z)*16)!=4) GenerateDunge((cx+x)*16,(cz+z)*16); } for(var x=-3;x<3;x++){ for(var z=-3;z<3;z++){ if(Level.getTile((cx+x)*16,1,(cz+z)*16)!=4) Level.setTile((cx+x)*16,1,(cz+z)*16,4); } } } } function GenerateDunge(x,z){ var y=0; for(var i=100;i>2;i--){ if(Level.getTile(x,i,z)!=0){ y=i; break; } } if(y==0 || (Level.getTile(x,y,z)!=2 && Level.getTile(x,y,z)!=1 && Level.getTile(x,y,z)!=3 && Level.getTile(x,y,z)!=31 && Level.getTile(x,y,z)!=37 && Level.getTile(x,y,z)!=38)) return; for(var xx=0; xx<=0; xx++){ for(var zz=0; zz<=0; zz++){ for(var air = 0;air<=0;air++){ if(Math.floor(Math.sqrt(xx*xx+zz*zz))==8|| (xx*xx==zz*zz) || (xx==0 || zz==0) || Math.floor(Math.sqrt(xx*xx+zz*zz))==7){
var ruin=[[x+(xx),y+(air),z+(zz),1]] for(var i=0;i Level.setTile(ruin[i][0],ruin[i][1],ruin[i][2],ruin[i][3]); setTile(x,y+1,z,57) setTile(x,y+2,z,57) setTile(x,y+3,z,57) setTile(x,y+4,z,57) setTile(x,y+5,z,57) setTile(x,y+6,z,57) setTile(x,y+7,z,57) setTile(x+1,y+6,z,41) setTile(x+1,y+7,z,41) setTile(x+2,y+6,z,41) setTile(x+2,y+7,z,41) setTile(x+1,y+6,z+1,41) setTile(x+1,y+7,z+1,41) setTile(x+1,y+6,z-1,41) setTile(x+1,y+7,z-1,41) setTile(x,y+6,z-1,41) setTile(x,y+7,z-1,41) setTile(x,y+6,z+1,41) setTile(x,y+7,z+1,41) setTile(x-1,y+6,z+1,41) setTile(x-1,y+7,z+1,41) setTile(x-1,y+6,z,41) setTile(x-1,y+7,z,41) setTile(x-1,y+6,z-1,41) setTile(x-1,y+7,z-1,41) setTile(x,y+8,z,41) setTile(x,y+9,z,41) setTile(x+1,y+8,z,41) setTile(x+1,y+9,z,41) setTile(x-1,y+8,z,41) setTile(x-1,y+9,z,41) setTile(x,y+8,z+1,41) setTile(x,y+9,z+1,41) setTile(x,y+8,z-1,41) setTile(x,y+9,z-1,41) setTile(x+2,y+6,z,41) setTile(x+2,y+7,z,41) setTile(x+2,y+6,z+1,41) setTile(x+2,y+7,z+1,41) setTile(x+2,y+6,z-1,41) setTile(x+2,y+7,z-1,41) setTile(x-2,y+6,z+1,41) setTile(x-2,y+7,z+1,41) setTile(x-2,y+6,z,41) setTile(x-2,y+7,z,41) setTile(x-2,y+6,z-1,41) setTile(x-2,y+7,z-1,41) setTile(x+1,y+6,z+2,41) setTile(x+1,y+7,z+2,41) setTile(x-1,y+6,z+2,41) setTile(x-1,y+7,z+2,41) setTile(x,y+6,z+2,41) setTile(x,y+7,z+2,41) setTile(x,y+6,z-2,41) setTile(x,y+7,z-2,41) setTile(x+1,y+6,z-2,41) setTile(x+1,y+7,z-2,41) setTile(x-1,y+8,z-2,41) setTile(x-1,y+7,z-2,41) setTile(x,y+10,z,5); a = x; b = y; c = z; } } } } }
|