Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let isInGame = false;
- const Thread_ = java.lang.Thread;
- const Handler_ = android.os.Handler;
- const Runnable_ = java.lang.Runnable;
- let treeCoords = [
- [+0,+1,0,17],
- [+0,+2,0,17],
- [+0,+3,0,17],
- [+0,+4,0,17],
- [+0,+5,0,17],
- [+0,+6,0,17],
- //Leaves
- [+2,+4,+2,18],
- [+1,+4,+2,18],
- [+0,+4,+2,18],
- [-1,+4,+2,18],
- [-2,+4,+2,18],
- [+2,+4,+1,18],
- [+1,+4,+1,18],
- [+0,+4,+1,18],
- [-1,+4,+1,18],
- [-2,+4,+1,18],
- [+2,+4,0,18],
- [+1,+4,0,18],
- [-1,+4,0,18],
- [-2,+4,0,18],
- [+2,+4,-1,18],
- [+1,+4,-1,18],
- [+0,+4,-1,18],
- [-1,+4,-1,18],
- [-2,+4,-1,18],
- [+2,+4,-2,18],
- [+1,+4,-2,18],
- [+0,+4,-2,18],
- [-1,+4,-2,18],
- //2nd layer
- [+2,+5,+2,18],
- [+1,+5,+2,18],
- [+0,+5,+2,18],
- [-1,+5,+2,18],
- [+2,+5,+1,18],
- [+1,+5,+1,18],
- [+0,+5,+1,18],
- [-1,+5,+1,18],
- [-2,+5,+1,18],
- [+2,+5,0,18],
- [+1,+5,0,18],
- [-1,+5,0,18],
- [-2,+5,0,18],
- [+2,+5,-1,18],
- [+1,+5,-1,18],
- [+0,+5,-1,18],
- [-1,+5,-1,18],
- [-2,+5,-1,18],
- [+2,+5,-2,18],
- [+1,+5,-2,18],
- [+0,+5,-2,18],
- [-1,+5,-2,18],
- [-2,+5,-2,18],
- //3rd layer
- [+0,+6,+1,18],
- [+1,+6,0,18],
- [-1,+6,0,18],
- [+1,+6,-1,18],
- [+0,+6,-1,18],
- //4th layer
- [+0,+7,+1,18],
- [+1,+7,0,18],
- [+0,+7,0,18],
- [-1,+7,0,18],
- [+0,+7,-1,18]
- ];
- let ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
- function delayFunction(func, delay) {
- ctx.runOnUiThread(new java.lang.Runnable({
- run: function() {
- new Handler_().postDelayed(
- new Runnable_() {
- run: func
- },
- delay);
- }
- }));
- }
- function buildTree(x, y, z, count) {
- if(count == null) {
- count = 0;
- }
- if(isInGame && count < treeCoords.length) {
- delayFunction(function() {
- let currentCoords = treeCoords[count];
- setTile(x + currentCoords[0], y + currentCoords[1], z + currentCoords[2], currentCoords[3]); //above or below setTile, you can add more functions
- buildTree(x, y, z, count + 1); //<< don't remove this part
- }, 320);
- }
- }
- function newLevel() {
- //make sure to add isInGame = true; into our own newLevel, example:
- isInGame = true;
- }
- function leaveGame() {
- isInGame = false;
- }
- function useItem(x, y, z) {
- //test
- //if you want to delay for 5 seconds before starting to build, do it like this:
- delayFunction(function() {
- buildTree(x, y, z);
- }, 5000); //<< 5000 is the amount of milliseconds
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement