//Mod made by DAW330073 //http://www.minecraftforum.net/index.php?showtopic=2624956  //Update 1.3 //Added Drill  var ex=[]; var wrenchEx=[]; var wrenchIm=[]; var wrenchFrqs=[]; var lastItem; var lastChestPart; var actualHealth; var lastY; var velY; var linking=false; var ButtonDown=false; var wrenchMode="linking"; var uBlocks=[]; var tickCounter=0; var bookOpened=false; var guidePage=0; var pBlocks=[]; var mBlocks=[]; var mBlocksSlots={"none":[0,0,0,0]}; var mBlocksProgress={"none":0}; var poweredBlocks=[]; var grinded={13:318,4:12,12:13}; var loaded=false;  var display=new android.util.DisplayMetrics(); com.mojang.minecraftpe.MainActivity.currentMainActivity.get().getWindowManager().getDefaultDisplay().getMetrics(display);  Block.defineBlock(180,"Barrel",[["itemframe_background",0],["piston_top_normal",0],["log",0],["log",0],["log",0],["log",0]],17,false,0); Block.setDestroyTime(180,2); Item.addCraftRecipe(180,1,0,[17,7,0,158,1,0]); Item.setCategory(180,8,0);  Block.defineBlock(181,"Extraction item pipe","piston_inner",20,false,0); Block.setColor(181,[0xCC6600]); Block.setDestroyTime(181,0.45); Item.addCraftRecipe(181,1,0,[182,1,0,331,2,0]); Item.setCategory(181,8,0);  Block.defineBlock(182,"Item pipe","piston_inner",20,false,0); Block.setDestroyTime(182,0.45); Item.addCraftRecipe(182,1,0,[463,6,0,20,3,0]); Item.setCategory(182,8,0);  Block.defineBlock(183,"Cobblestone generator",[["stonecutter",2],["stonecutter",2],["stonecutter",3],["stonecutter",3],["stonecutter",3],["stonecutter",3]],20,false,0); Block.setDestroyTime(183,0.45); Item.addCraftRecipe(183,1,0,[20,2,0,257,1,0,1,6,0]); Item.setCategory(183,8,0);  Block.defineBlock(184,"Farmer",[["stonecutter",2],["hayblock",0],["stonecutter",3],["stonecutter",3],["stonecutter",3],["stonecutter",3]],20,false,0); Block.setDestroyTime(184,0.45); Item.addCraftRecipe(184,1,0,[265,3,0,294,1,0,463,5,0]); Item.setCategory(184,8,0);  Block.defineBlock(188,"Tree farmer",[["stonecutter",2],["planks",0],["stonecutter",3],["stonecutter",3],["stonecutter",3],["stonecutter",3]],20,false,0); Block.setDestroyTime(188,0.45); Item.addCraftRecipe(188,1,0,[265,3,0,268,1,0,463,5,0]); Item.setCategory(188,8,0);  ModPE.setItem(460,"sign",0,"wrench",1); ModPE.langEdit("item.wrench.name","Linking Wrench"); Item.addCraftRecipe(460,1,0,[264,4,0]); Item.setCategory(460,2,0);  ModPE.langEdit("item.bootsChain.name","G-Defy Boots"); Item.addCraftRecipe(305,1,0,[463,4,0]); Item.setCategory(305,2,0);  ModPE.langEdit("item.chestplateChain.name","Jetpack"); Item.addCraftRecipe(303,1,0,[265,5,0,463,1,0,331,2,0]); Item.setCategory(303,2,0);  ModPE.langEdit("item.helmetChain.name","HUD"); Item.addCraftRecipe(302,1,0,[265,5,0,331,1,0]); Item.setCategory(302,2,0);  Block.defineBlock(191,"Stone generator",[["stonecutter",2],["stone",0],["stonecutter",3],["stonecutter",3],["stonecutter",3],["stonecutter",3]],20,false,0); Block.setDestroyTime(191,0.45); Item.addCraftRecipe(191,1,0,[20,2,0,257,1,0,1,6,0]); Item.setCategory(191,8,0);  Block.defineBlock(192,"Obsidian generator",[["stonecutter",2],["obsidian",0],["stonecutter",3],["stonecutter",3],["stonecutter",3],["stonecutter",3]],20,false,0); Block.setDestroyTime(192,0.45); Item.addCraftRecipe(192,1,0,[20,2,0,257,1,0,1,6,0]); Item.setCategory(192,8,0);  ModPE.setItem(461,"book_written",0,"guide",1); ModPE.langEdit("item.guide.name","ExtendedCraft Guide"); Item.addCraftRecipe(461,1,0,[340,1,0]); Item.setCategory(461,2,0);  Block.defineBlock(193,"Solar Panel",[["coal_block",0],["redstone_lamp_off",0],["coal_block",0],["coal_block",0],["coal_block",0],["coal_block",0]],20,false,0); Block.setShape(193,0,0,0,1,0.2,1); Block.setDestroyTime(193,0.45); Item.addCraftRecipe(193,1,0,[102,3,0,194,3,0,265,3,0]); Item.setCategory(193,8,0);  Block.defineBlock(194,"Wire",[["quartz_block",6],["quartz_block",6],["quartz_block",6],["quartz_block",6],["quartz_block",6],["quartz_block",6]],20,false,0); Block.setColor(194,[0xCC6633]); Block.setDestroyTime(194,0.45); Item.addCraftRecipe(194,1,0,[463,6,0,265,3,0]); Item.setCategory(194,8,0);  ModPE.setItem(462,"painting",0,"powerMeter",1); ModPE.langEdit("item.powerMeter.name","Power Meter"); Item.addCraftRecipe(462,1,0,[331,5,0,194,3,0,323,1,0]); Item.setCategory(462,2,0);  Block.defineBlock(195,"Grinder",[["iron_block",0],["iron_block",0],["furnace",2],["furnace",2],["furnace",2],["furnace",2]],20,false,0); Block.setDestroyTime(195,0.45); Item.addCraftRecipe(195,1,0,[194,2,0,199,1,0]); Item.setCategory(195,8,0);  Block.defineBlock(196,"Rubber Sapling","sapling",6,false,1); Block.setColor(196,[0x85C272]); Block.setDestroyTime(196,0.1);  Block.defineBlock(197,"Rubber Wood",[["log",5],["log",5],["log",4],["log",4],["log",4],["log",4]],17,false,0); Block.setColor(197,[0x5C3E33]); Block.setDestroyTime(197,2);  Block.defineBlock(198,"Rubber Leaves",[["leaves",7],["leaves",7],["leaves",7],["leaves",7],["leaves",7],["leaves",7]],18,false,0); Block.setColor(198,[0x61845B]); Block.setDestroyTime(198,0.2);  ModPE.setItem(463,"slimeball",0,"rubber",64); ModPE.langEdit("item.rubber.name","Rubber"); Item.addFurnaceRecipe(197,463,0);  Block.defineBlock(199,"Machine Block","iron_block",20,false,0); Block.setDestroyTime(199,0.4); Item.addCraftRecipe(199,1,0,[265,8,0]);  Block.defineBlock(200,"Drill",[["iron_block",0],["iron_block",0],["stonecutter",2],["stonecutter",2],["stonecutter",2],["stonecutter",2]],20,false,0); Block.setDestroyTime(200,0.45); Item.addCraftRecipe(200,1,0,[278,1,0,199,2,0,265,2,0,194,3,0]); Item.setCategory(200,8,0);  Block.defineBlock(201,"drill",[["quartz_block",3],["quartz_block",3],["quartz_block",3],["quartz_block",3],["quartz_block",3],["quartz_block",3]],20,false,7); Block.setColor(201,[0x999999]); Block.setShape(201,0.4,0,0.4,0.6,1,0.6);  function procCmd(cmd){ 	switch(cmd){ 		case "day": 			Level.setTime(0); 			break; 		case "kill": 			Player.setHealth(0); 			break; 		case "rubber": 			GrowTree(parseInt(Player.getX()),parseInt(Player.getY())-1,parseInt(Player.getZ())); 			break; 		} 	}  function modTick(){ 	if(lastItem!=Player.getCarriedItem() && (lastItem==460 || Player.getCarriedItem()==460)){ 		if(lastItem==460) 			HideWrenchGUI(); 		else 			ShowWrenchGUI(); 		} 	if(lastItem!=Player.getCarriedItem() && (lastItem==461 || Player.getCarriedItem()==461)){ 		if(lastItem==461) 			HideGuideGUI(); 		else 			ShowGuideGUI(); 		} 	lastItem=Player.getCarriedItem(); 	if(lastChestPart!=Player.getArmorSlot(1) && (lastChestPart==303 || Player.getArmorSlot(1)==303)){ 		if(lastChestPart==303) 			HideJetpackGUI(); 		else 			ShowJetpackGUI(); 		} 	lastChestPart=Player.getArmorSlot(1); 	velY=(Player.getY()-lastY)/(1/20); 	lastY=Player.getY(); 	if(Player.getArmorSlot(3)==305){ 		if(Entity.getHealth(Player.getEntity())<=25) 			actualHealth=Entity.getHealth(Player.getEntity()); 		if(velY<-12 && Level.getTile(parseInt(Player.getX()),parseInt(Player.getY())-12,parseInt(Player.getZ()))!=0) 			Player.setHealth(Entity.getHealth(Player.getEntity())-velY); 		if(velY>-3 && Level.getTile(parseInt(Player.getX()),parseInt(Player.getY())-2,parseInt(Player.getZ()))!=0) 			Player.setHealth(actualHealth); 		} 	if(ButtonDown){ 		if(velY<0) 			Entity.setVelY(Player.getEntity(),0); 		if(velY>=0 && velY<0.6) 			Entity.setVelY(Player.getEntity(),velY+0.006); 		if(velY>=0.6) 			Entity.setVelY(Player.getEntity(),0.6); 		} 	tickCounter++; 	if(tickCounter==40){ 		renderHelmetGUI(); 		tickCounter=0; 		if(ex.length>0){ 			for(var i=0;i<ex.length;i++){ 				if(Level.getTile(ex[i][0],ex[i][1],ex[i][2])==181){ 					var sides=[[ex[i][0],ex[i][1]-1,ex[i][2]],[ex[i][0],ex[i][1]+1,ex[i][2]],[ex[i][0],ex[i][1],ex[i][2]-1],[ex[i][0],ex[i][1],ex[i][2]+1],[ex[i][0]-1,ex[i][1],ex[i][2]],[ex[i][0]+1,ex[i][1],ex[i][2]]]; 					var cx,cy,cz; 					for(var j=0;j<6;j++){ 						if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==54 || Level.getTile(sides[j][0],sides[j][1],sides[j][2])==61 || Level.getTile(sides[j][0],sides[j][1],sides[j][2])==62){ 							cx=sides[j][0]; 							cy=sides[j][1]; 							cz=sides[j][2]; 							break; 							} 						else if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==180){ 							var sides=[[sides[j][0],sides[j][1]-1,sides[j][2]],[sides[j][0],sides[j][1]+1,sides[j][2]],[sides[j][0],sides[j][1],sides[j][2]-1],[sides[j][0],sides[j][1],sides[j][2]+1],[sides[j][0]-1,sides[j][1],sides[j][2]],[sides[j][0]+1,sides[j][1],sides[j][2]]]; 							for(var k=0;k<6;k++){ 								if(Level.getTile(sides[k][0],sides[k][1],sides[k][2])==68 && Level.getSignText(sides[k][0],sides[k][1],sides[k][2],0)=="Barrel"){ 									cx=sides[k][0]; 									cy=sides[k][1]; 									cz=sides[k][2]; 									break; 									} 								} 							} 						} 					MoveItems([cx,cy,cz],FindChest(ex[i][0],ex[i][1],ex[i][2]),1); 					} 				else 					ex.splice(i,1); 				} 			} 		if(wrenchEx.length>0){ 			for(var i=0;i<wrenchEx.length;i++){ 				if(wrenchFrqs[i]==1) 					MoveItems(wrenchEx[i],wrenchIm[i],1); 				} 			} 		if(uBlocks.length>0){ 			for(var i=0;i<uBlocks.length;i++){ 				if(Level.getTile(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2])==183)	//Cobblestone 					Generator(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2],4,0,1); 				else if(Level.getTile(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2])==184)	//Seeds 					Farmer(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2],2); 				else if(Level.getTile(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2])==188)	//Trees 					TreeFarmer(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2],2); 				else if(Level.getTile(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2])==191)	//Stone 					Generator(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2],1,0,1); 				else if(Level.getTile(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2])==192)	//Obsidian 					Generator(uBlocks[i][0],uBlocks[i][1],uBlocks[i][2],49,0,1); 				else 					uBlocks.splice(i,1); 				} 			} 		CheckTheWires(); 		} 	if(!loaded && Level.getTile(parseInt(Player.getX()),parseInt(Player.getY())-2,parseInt(Player.getZ()))!=0){ 		if(Level.getTile(1,1,1)!=197){ 			for(var i=0;i<Math.floor(Math.random()*11)+15;i++){ 				var x=Math.floor(Math.random()*245)+10; 				var z=Math.floor(Math.random()*245)+10; 				var y=FindHighestY(x,z); 				if(Level.getTile(x,y,z)==2) 					GrowTree(x,y+1,z); 				} 			Level.setTile(1,1,1,197); 			} 		loaded=true; 		} 	Machines(); 	}  function useItem(x,y,z,itemID,blockID,side){ 	if(blockID==196 && itemID==351 && Player.getCarriedItemData()==15) 		GrowTree(x,y,z); 	if(itemID==462){ 		preventDefault(); 		if(InArray([x,y,z],poweredBlocks)) 			clientMessage("Power flowing."); 		else 			clientMessage("No power."); 		} 	if(itemID==195 || itemID==200){ 		preventDefault(); 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		PlaceBlock(x,y,z,side,itemID,0); 		if(!InArray([x,y,z],mBlocks)){ 			mBlocks.push([sides[side][0],sides[side][1],sides[side][2]]); 			if(itemID==195){ 				if(!mBlocksSlots[sides[side][0]+","+sides[side][1]+","+sides[side][2]]) 					mBlocksSlots[sides[side][0]+","+sides[side][1]+","+sides[side][2]]=[0,0,0,0]; 				if(!mBlocksProgress[sides[side][0]+","+sides[side][1]+","+sides[side][2]]) 					mBlocksProgress[sides[side][0]+","+sides[side][1]+","+sides[side][2]]=0; 				} 			} 		} 	if(blockID==195 || blockID==200){ 		preventDefault(); 		if(!InArray([x,y,z],mBlocks)){ 			mBlocks.push([x,y,z]); 			if(blockID==195){ 				if(!mBlocksSlots[x+","+y+","+z]) 					mBlocksSlots[x+","+y+","+z]=[0,0,0,0]; 				if(!mBlocksProgress[x+","+y+","+z]) 					mBlocksProgress[x+","+y+","+z]=0; 				} 			} 		if(blockID==195) 			ShowMachineGUI(x+","+y+","+z); 		}  	if(itemID>192 && itemID<195){ 		preventDefault(); 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		PlaceBlock(x,y,z,side,itemID,0); 		if(!InArray([x,y,z],pBlocks)) 			pBlocks.push([sides[side][0],sides[side][1],sides[side][2]]); 		} 	if(blockID>192 && blockID<195){ 		if(!InArray([x,y,z],pBlocks)) 			pBlocks.push([x,y,z]); 		} 	CheckTheWires(); 	if(Player.getArmorSlot(0)==302) 		renderHelmetGUI(); 	if(itemID>182 && itemID<193){ 		preventDefault(); 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		PlaceBlock(x,y,z,side,itemID,0); 		if(!InArray([x,y,z],uBlocks)) 			uBlocks.push([sides[side][0],sides[side][1],sides[side][2]]); 		} 	if(blockID>182 && blockID<193){ 		if(!InArray([x,y,z],uBlocks)) 			uBlocks.push([x,y,z]); 		} 	if(itemID==181){ 		preventDefault(); 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		PlaceBlock(x,y,z,side,181,0); 		x=sides[side][0]; 		y=sides[side][1]; 		z=sides[side][2]; 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		for(var i=0;i<6;i++){ 			if((Level.getTile(sides[i][0],sides[i][1],sides[i][2])==54 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==61 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==62) && !InArray(sides[i],ex)){ 				ex.push([x,y,z]); 				break; 				} 			else if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==180){ 				sides=[[sides[i][0],sides[i][1]-1,sides[i][2]],[sides[i][0],sides[i][1]+1,sides[i][2]],[sides[i][0],sides[i][1],sides[i][2]-1],[sides[i][0],sides[i][1],sides[i][2]+1],[sides[i][0]-1,sides[i][1],sides[i][2]],[sides[i][0]+1,sides[i][1],sides[i][2]]]; 				for(var j=0;j<6;j++){ 					if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==68 && Level.getSignText(sides[j][0],sides[j][1],sides[j][2],0)=="Barrel"){ 						ex.push([x,y,z]); 						break; 						} 					} 				break; 				} 			} 		} 	if(blockID==181){ 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		for(var i=0;i<6;i++){ 			if((Level.getTile(sides[i][0],sides[i][1],sides[i][2])==54 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==61 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==62) && !InArray(sides[i],ex)){ 				ex.push([x,y,z]); 				break; 				} 			else if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==180){ 				sides=[[sides[i][0],sides[i][1]-1,sides[i][2]],[sides[i][0],sides[i][1]+1,sides[i][2]],[sides[i][0],sides[i][1],sides[i][2]-1],[sides[i][0],sides[i][1],sides[i][2]+1],[sides[i][0]-1,sides[i][1],sides[i][2]],[sides[i][0]+1,sides[i][1],sides[i][2]]]; 				for(var j=0;j<6;j++){ 					if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==68 && Level.getSignText(sides[j][0],sides[j][1],sides[j][2],0)=="Barrel"){ 						ex.push([x,y,z]); 						break; 						} 					} 				break; 				} 			} 		} 	if(itemID==180 && blockID!=68){ 		preventDefault(); 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		var finalPos=[sides[side][0],sides[side][1],sides[side][2]]; 		if(side!=1) 			var sides=[[sides[side][0],sides[side][1]+1,sides[side][2]],[sides[side][0],sides[side][1]-1,sides[side][2]],[sides[side][0],sides[side][1],sides[side][2]-1],[sides[side][0],sides[side][1],sides[side][2]+1],[sides[side][0]-1,sides[side][1],sides[side][2]],[sides[side][0]+1,sides[side][1],sides[side][2]]]; 		else{ 			var rot=getYaw(); 			if(rot<0) 				rot=-rot; 			while(rot>=360) 				rot-=360; 			if(rot>=45 && rot<=135) 				side=2; 			if(rot>=135 && rot<=225) 				side=3; 			if(rot>=225 && rot<=315) 				side=4; 			if((rot>0 && rot<=45) || (rot>=315 && rot<=360)) 				side=5; 			var sides=[[finalPos[0],finalPos[1]-1,finalPos[2]],[finalPos[0],finalPos[1]+1,finalPos[2]],[finalPos[0],finalPos[1],finalPos[2]-1],[finalPos[0],finalPos[1],finalPos[2]+1],[finalPos[0]-1,finalPos[1],finalPos[2]],[finalPos[0]+1,finalPos[1],finalPos[2]]]; 			} 		if(Level.getTile(finalPos[0],finalPos[1],finalPos[2])==0 && Level.getTile(sides[side][0],sides[side][1],sides[side][2])==0){ 			Level.setTile(finalPos[0],finalPos[1],finalPos[2],180,0); 			Level.setTile(sides[side][0],sides[side][1],sides[side][2],68,side); 			Level.setSignText(sides[side][0],sides[side][1],sides[side][2],0,"Barrel"); 			Level.setSignText(sides[side][0],sides[side][1],sides[side][2],3,"Barrel"); 			if(Player.getCarriedItemCount()>1) 				Entity.setCarriedItem(Player.getEntity(),Player.getCarriedItem(),Player.getCarriedItemCount()-1,Player.getCarriedItemData()); 			else{ 				for(var i=0;i<9;i++){ 					if(Player.getInventorySlot(i)==Player.getCarriedItem() && Player.getInventorySlotData(i)==Player.getCarriedItemData() && Player.getInventorySlotCount(i)==Player.getCarriedItemCount()){ 						Player.clearInventorySlot(i); 						break; 						} 					} 				} 			} 		} 	if(blockID==68 && itemID!=460){ 		preventDefault(); 		var sides=[[x,y+1,z],[x,y-1,z],[x,y,z+1],[x,y,z-1],[x+1,y,z],[x-1,y,z]]; 		if(Player.getCarriedItem()!=0) 			var name=GetItemBlockName(Player.getCarriedItem()+":"+Player.getCarriedItemData()); 		else 			var name="hand"; 		if(name!="hand" && Level.getSignText(x,y,z,0)=="Barrel" && Level.getSignText(x,y,z,3)=="Barrel" && Level.getTile(sides[Level.getData(x,y,z)][0],sides[Level.getData(x,y,z)][1],sides[Level.getData(x,y,z)][2])==180){ 			Level.setSignText(x,y,z,3,Player.getCarriedItem()+":"+Player.getCarriedItemData()); 			Level.setSignText(x,y,z,1,name); 			if(Player.getCarriedItemCount()==64) 				Level.setSignText(x,y,z,2,"1x64+0"); 			else 				Level.setSignText(x,y,z,2,"0x64+"+Player.getCarriedItemCount()); 			for(var i=0;i<9;i++){ 				if(Player.getInventorySlot(i)==Player.getCarriedItem() && Player.getInventorySlotData(i)==Player.getCarriedItemData() && Player.getInventorySlotCount(i)==Player.getCarriedItemCount()){ 					Player.clearInventorySlot(i); 					break; 					} 				} 			} 		else if(name!="hand" && Level.getSignText(x,y,z,0)=="Barrel" && Level.getSignText(x,y,z,1)==name && Level.getTile(sides[Level.getData(x,y,z)][0],sides[Level.getData(x,y,z)][1],sides[Level.getData(x,y,z)][2])==180){ 			var itemCount=64*parseInt(Level.getSignText(x,y,z,2).split("x")[0])+parseInt(Level.getSignText(x,y,z,2).split("+")[1]); 			if(itemCount<4096 && itemCount+Player.getCarriedItemCount()<=4096){ 				itemCount+=Player.getCarriedItemCount(); 				Level.setSignText(x,y,z,2,parseInt(itemCount/64)+"x64+"+(itemCount-parseInt(itemCount/64)*64)); 				for(var i=0;i<9;i++){ 					if(Player.getInventorySlot(i)==Player.getCarriedItem() && Player.getInventorySlotData(i)==Player.getCarriedItemData() && Player.getInventorySlotCount(i)==Player.getCarriedItemCount()){ 						Player.clearInventorySlot(i); 						break; 						} 					} 				} 			else if(itemCount<4096 && itemCount+Player.getCarriedItemCount()>4096){ 				for(var i=0;i<9;i++){ 					if(Player.getInventorySlot(i)==Player.getCarriedItem() && Player.getInventorySlotData(i)==Player.getCarriedItemData()){ 						net.zhuoweizhang.mcpelauncher.ScriptManager.nativeSetInventorySlot(i,Player.getCarriedItem(),Player.getInventorySlotCount(i)-(4096-itemCount),Player.getCarriedItemData()); 						break; 						} 					} 				itemCount=4096; 				Level.setSignText(x,y,z,2,parseInt(itemCount/64)+"x64+"+(itemCount-parseInt(itemCount/64)*64)); 				} 			} 		else if(Level.getSignText(x,y,z,0)=="Barrel" && Level.getSignText(x,y,z,3)!="Barrel" && Level.getSignText(x,y,z,1)!=name && Level.getTile(sides[Level.getData(x,y,z)][0],sides[Level.getData(x,y,z)][1],sides[Level.getData(x,y,z)][2])==180){ 			var itemCount=64*parseInt(Level.getSignText(x,y,z,2).split("x")[0])+parseInt(Level.getSignText(x,y,z,2).split("+")[1]); 			if(itemCount<=64){ 				Level.dropItem(Player.getX(),Player.getY(),Player.getZ(),0,Level.getSignText(x,y,z,3).split(":")[0],itemCount,Level.getSignText(x,y,z,3).split(":")[1]); 				Level.setSignText(x,y,z,1," "); 				Level.setSignText(x,y,z,2," "); 				Level.setSignText(x,y,z,3,"Barrel"); 				} 			else{ 				Level.dropItem(Player.getX(),Player.getY(),Player.getZ(),0,Level.getSignText(x,y,z,3).split(":")[0],64,Level.getSignText(x,y,z,3).split(":")[1]); 				itemCount-=64; 				Level.setSignText(x,y,z,2,parseInt(itemCount/64)+"x64+"+(itemCount-parseInt(itemCount/64)*64)); 				} 			} 		} 	if(itemID==460){ 		if(wrenchMode!="none") 			preventDefault(); 		if(wrenchMode=="linking" && blockID==54){ 			if(!linking){ 				linkingChest=[x,y,z]; 				clientMessage("Link started at: "+[x,y,z]); 				linking=true; 				} 			else if(linking){ 				if(x==linkingChest[0] && y==linkingChest[1] && z==linkingChest[2]) 					clientMessage("Can't link to this chest..."); 				else{ 					wrenchEx.push(linkingChest); 					wrenchIm.push([x,y,z]); 					wrenchFrqs.push(1); 					clientMessage("Linked to: "+[x,y,z]); 					linkingChest=null; 					linking=false; 					} 				} 			} 		if(wrenchMode=="linking" && blockID==68 && Level.getSignText(x,y,z,0)=="Barrel"){ 			if(!linking){ 				linkingChest=[x,y,z]; 				clientMessage("Link started at: "+[x,y,z]); 				linking=true; 				} 			else if(linking){ 				if(x==linkingChest[0] && y==linkingChest[1] && z==linkingChest[2]) 					clientMessage("Can't link to this barrel..."); 				else{ 					wrenchEx.push(linkingChest); 					wrenchIm.push([x,y,z]); 					wrenchFrqs.push(1); 					clientMessage("Linked to: "+[x,y,z]); 					linkingChest=null; 					linking=false; 					} 				} 			} 		if(wrenchMode=="linking" && (blockID==61 ||blockID==62)){ 			if(!linking){ 				if(side!=1){ 					linkingChest=[x,y,z]; 					clientMessage("Link started at: "+[x,y,z]); 					linking=true; 					} 				else 					clientMessage("That's input side..."); 				} 			else if(linking){ 				if(x==linkingChest[0] && y==linkingChest[1] && z==linkingChest[2]) 					clientMessage("Can't link to this furnace..."); 				else{ 					if(side==1){ 						wrenchEx.push(linkingChest); 						wrenchIm.push([x,y,z]); 						wrenchFrqs.push(1); 						clientMessage("Linked to: "+[x,y,z]); 						linkingChest=null; 						linking=false; 						} 					else 						clientMessage("That's output side..."); 					} 				} 			} 		if(wrenchMode=="unlinking" && (blockID==54 || blockID==61 || blockID==62 || (blockID==68 && Level.getSignText(x,y,z,0)=="Barrel"))){ 			var didSomething=false; 			for(var i=0;i<wrenchEx.length;i++){ 				if(wrenchFrqs[i]==1 && ((wrenchEx[i][0]==x && wrenchEx[i][1]==y && wrenchEx[i][2]==z) || (wrenchIm[i][0]==x && wrenchIm[i][1]==y && wrenchIm[i][2]==z))){ 					wrenchFrqs[i]=0; 					clientMessage("Unlinked "+wrenchEx[i]+" and "+[x,y,z]); 					didSomething=true; 					} 				} 			if(!didSomething && blockID==54) 				clientMessage("This chest isn't linked..."); 			if(!didSomething && (blockID==61 || blockID==62)) 				clientMessage("This furnace isn't linked..."); 			if(!didSomething && blockID==68) 				clientMessage("This barrel isn't linked..."); 			} 		} 	}  function attackHook(attacker,victim){ 	if(Player.getArmorSlot(0)==302) 		renderHelmetGUI(); 	} 	 function destroyBlock(x,y,z,side){ 	poweredBlocks=[]; 	if(Level.getTile(x,y,z)==193 || Level.getTile(x,y,z)==194){ 		preventDefault(); 		Level.destroyBlock(x,y,z,true); 		} 	CheckTheWires();  	if(Level.getTile(x,y,z)==68 && Level.getSignText(x,y,z,0)!="Barrel") 		Level.destroyBlock(x,y,z,true); 	if(Level.getTile(x,y,z)==198){ 		Level.destroyBlock(x,y,z,false); 		if(Chances(10)) 			Level.dropItem(x,y,z,0,196,1,0); 		} 	if(Level.getTile(x,y,z)==200){ 		Level.destroyBlock(x,y,z,true); 		for(var i=0;i<y;i++){ 			if(Level.getTile(x,y-i,z)==201) 				Level.setTile(x,y-i,z,0); 			} 		} 	var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 	if(Level.getTile(x,y,z)==180){ 		for(var i=0;i<6;i++){ 			if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==68 && Level.getSignText(sides[i][0],sides[i][1],sides[i][2],0)=="Barrel"){ 				if(Level.getSignText(sides[i][0],sides[i][1],sides[i][2],3)=="Barrel"){ 					Level.destroyBlock(sides[i][0],sides[i][1],sides[i][2],false); 					Level.destroyBlock(x,y,z,true); 					break; 					} 				else if(Level.getSignText(sides[i][0],sides[i][1],sides[i][2],3)!="Barrel"){ 					Level.dropItem(x,y,z,0,parseInt(Level.getSignText(sides[i][0],sides[i][1],sides[i][2],3).split(":")[0]),64*parseInt(Level.getSignText(sides[i][0],sides[i][1],sides[i][2],2).split("x")[0])+parseInt(Level.getSignText(sides[i][0],sides[i][1],sides[i][2],2).split("+")[1]),parseInt(Level.getSignText(sides[i][0],sides[i][1],sides[i][2],3).split(":")[1])); 					Level.destroyBlock(sides[i][0],sides[i][1],sides[i][2],false); 					Level.destroyBlock(x,y,z,true); 					break; 					} 				else{ 					Level.destroyBlock(sides[i][0],sides[i][1],sides[i][2],false); 					Level.destroyBlock(x,y,z,true); 					break; 					} 				} 			} 		} 	else if(Level.getTile(x,y,z)==68 && Level.getSignText(x,y,z,0)=="Barrel"){ 		for(var i=0;i<6;i++){ 			if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==180){ 				if(Level.getSignText(x,y,z,3)=="Barrel"){ 					Level.destroyBlock(x,y,z,false); 					Level.destroyBlock(sides[i][0],sides[i][1],sides[i][2],true); 					break; 					} 				else if(Level.getSignText(x,y,z,3)!="Barrel"){ 					Level.dropItem(x,y,z,0,parseInt(Level.getSignText(x,y,z,3).split(":")[0]),64*parseInt(Level.getSignText(x,y,z,2).split("x")[0])+parseInt(Level.getSignText(x,y,z,2).split("+")[1]),parseInt(Level.getSignText(x,y,z,3).split(":")[1])); 					Level.destroyBlock(x,y,z,false); 					Level.destroyBlock(sides[i][0],sides[i][1],sides[i][2],true); 					break; 					} 				} 			} 		} 	}  function leaveGame(){ 	ex=[]; 	wrenchEx=[]; 	wrenchIm=[]; 	wrenchFrqs=[]; 	linking=false; 	wrenchMode="linking"; 	uBlocks=[]; 	HideWrenchGUI(); 	HideJetpackGUI(); 	HideGuideGUI(); 	pBlocks=[]; 	poweredBlocks=[]; 	HideMachineGUI(); 	mBlocks=[]; 	mBlocksSlots={"none":[0,0,0,0]}; 	mBlocksProgress={"none":0}; 	loaded=false; 	}  function renderHelmetGUI(){ 	if(Player.getArmorSlot(0)==302){ 		var types={10:"Chicken",11:"Cow",12:"Pig",13:"Sheep",32:"Zombie",34:"Skeleton",35:"Spider",33:"Creeper",36:"Zombie Pigman"}; 		for(var i=0;i<Entity.getAll().length;i++){ 			var ent=Entity.getEntityTypeId(Entity.getAll()[i]); 			if(ent>9 && ent<14) 				Entity.setNameTag(Entity.getAll()[i],types[ent]+"\nHealth: "+Entity.getHealth(Entity.getAll()[i])); 			if(ent>31 && ent<37) 				Entity.setNameTag(Entity.getAll()[i],types[ent]+"\nHealth: "+Entity.getHealth(Entity.getAll()[i])); 			} 		} 	else{ 		for(var i=0;i<Entity.getAll().length;i++){ 			var ent=Entity.getEntityTypeId(Entity.getAll()[i]); 			if(((ent>9 && ent<14) || (ent>31 && ent<37)) && Entity.getNameTag(Entity.getAll()[i])) 				Entity.setNameTag(Entity.getAll()[i],""); 			} 		} 	}  function GrowTree(x,y,z){ 	Level.setTile(x,y,z,197); 	Level.setTile(x,y+1,z,197); 	Level.setTile(x,y+2,z,197); 	Level.setTile(x,y+3,z,197); 	Level.setTile(x,y+4,z,198); 	//Level.setTile(x-1,y+4,z,198); 	//Level.setTile(x+1,y+4,z,198); 	//Level.setTile(x,y+4,z-1,198); 	//Level.setTile(x,y+4,z+1,198); 	Level.setTile(x-1,y+3,z,198); 	Level.setTile(x+1,y+3,z,198); 	Level.setTile(x,y+3,z-1,198); 	Level.setTile(x,y+3,z+1,198); 	Level.setTile(x-1,y+2,z,198); 	Level.setTile(x+1,y+2,z,198); 	Level.setTile(x,y+2,z-1,198); 	Level.setTile(x,y+2,z+1,198); 	Level.setTile(x-1,y+2,z-1,198); 	Level.setTile(x+1,y+2,z-1,198); 	Level.setTile(x-1,y+2,z+1,198); 	Level.setTile(x+1,y+2,z+1,198); 	}  function GetItemBlockName(id){ 	var IDs={ 		"0:0":"","1:0":"Stone","2:0":"Grass","3:0":"Dirt","4:0":"Cobblestone","5:0":"Wooden Plank","6:0":"Oak Sapling","6:1":"Spruce Sapling","6:2":"Birch Sapling","7:0":"Bedrock","8:0":"Water","9:0":"Stationary water","10:0":"Lava","11:0":"Stationary lava","12:0":"Sand","13:0":"Gravel","14:0":"Gold Ore","15:0":"Iron Ore","16:0":"Coal Ore","17:0":"Oak Log","17:1":"Spruce Log","17:2":"Birch Log","18:0":"Oak Leaves","18:1":"Spruce Leaves","18:2":"Birch Leaves","19:0":"Sponge","20:0":"Glass","21:0":"Lapis Lazuli Ore","22:0":"Lapis Lazuli Block","24:0":"Sandstone","24:1":"Chiseled Sandstone","24:2":"Smooth Sandstone","26:0":"Bed Block","27:0":"Powered Rail","30:0":"Cobweb","31:0":"Dead Shrub","32:0":"Dead Bush","35:0":"White Wool","35:1":"Orange Wool","35:2":"Magenta Wool","35:3":"Light Blue Wool","35:4":"Yellow Wool","35:5":"Lime Green Wool","35:6":"Pink Wool","35:7":"Gray Wool","35:8":"Light Gray Wool","35:9":"Cyan Wool","35:10":"Purple Wool","35:11":"Blue Wool","35:12":"Brown Wool","35:13":"Green Wool","35:14":"Red Wool","35:15":"Black Wool","37:0":"Yellow Flower","38:0":"Cyan Flower","39:0":"Brown Mushroom","40:0":"Red Mushroom","41:0":"Gold Block","42:0":"Iron Block","43:0":"Double Slab (Stone)","43:1":"Double Slab (Sandstone)","43:2":"Double Slab (Wood)","43:3":"Double Slab (Cobblestone)","43:4":"Double Slab (Brick)","43:6":"Double Slab (Stone)","44:0":"Slab (Stone)","44:1":"Slab (Sandstone)","44:2":"Slab (Wood)","44:3":"Slab (Cobblestone)","44:4":"Slab (Brick)","44:5":"Slab (Stone Brick)","44:6":"Slab (Stone)","44:7":"Slab (Quartz)","45:0":"Brick Block","46:0":"TNT","47:0":"Bookshelf","48:0":"Moss Stone","49:0":"Obsidian", 		"50:0":"Torch","51:0":"Fire","53:0":"Wooden Stairs","54:0":"Chest","56:0":"Diamond Ore","57:0":"Diamond Block","58:0":"Crafting Table","59:0":"Crops","60:0":"Farmland","61:0":"Furnace","62:0":"Burning Furnace","63:0":"Sign Post","64:0":"Wooden Door","65:0":"Ladder","66:0":"Rail","67:0":"Cobblestone Stairs","68:0":"Wall Sign","71:0":"Iron Door","73:0":"Redstone Ore","74:0":"Glowing Redstone Ore","78:0":"Snow","79:0":"Ice","80:0":"Snow Block","81:0":"Cactus","82:0":"Clay Block","83:0":"Sugar Cane","85:0":"Fence","86:0":"Pumpkin","87:0":"Netherrack","89:0":"Glowstone","91:0":"Jack 'o' Lantern","92:0":"Cake","95:0":"Invisible bedrock","96:0":"Trapdoor","98:0":"Stone Bricks","98:1":"Stone Brick (mossy)","98:2":"Stone Brick (cracked)", 		"101:0":"Iron Bars","102:0":"Glass Pane","103:0":"Melon","104:0":"Pumpkin Stem","105:0":"Melon Stem","107:0":"Fence Gate","108:0":"Brick Stairs","109:0":"Stone Brick Stairs","112:0":"Nether Brick","114:0":"Nether Brick Stairs","126:0":"Cake","128:0":"Sandstone Stairs","134:0":"Spruce Stairs","135:0":"Birch Stairs","136:0":"Jungle Stairs","139:0":"Cobblestone Wall","141:0":"Carrot","142:0":"Potato", 		"155:0":"Block of Quartz","155:1":"Chiseled Quartz Block","155:2":"Pillar Quartz Block","156:0":"Quartz Stairs","157:0":"Wooden Double Stairs","158:0":"Wooden Slab","170:0":"Hey Bale","171:0":"Carpet","173:0":"Block of Coal", 		"244:0":"Beetroot","245:0":"Stone Cutter","246:0":"Glowing Obsidian","247:0":"Nether Reactor Core","248:0":"Update","249:0":"Update","253:0":"Update","254:0":"Update","255:0":"Update", 		"256:0":"Iron Shovel","257:0":"Iron Pickaxe","258:0":"Iron Axe","259:0":"Flint and Steel","260:0":"Apple","261:0":"Bow","262:0":"Arrow","263:0":"Coal","263:1":"Charcoal","264:0":"Diamond","265:0":"Iron Ingot","266:0":"Gold Ingot","267:0":"Iron Sword","268:0":"Wooden Sword","269:0":"Wooden Shovel","270:0":"Wooden Pickaxe","271:0":"Wooden Axe","272:0":"Stone Sword","273:0":"Stone Shovel","274:0":"Stone Pickaxe","275:0":"Stone Axe","276:0":"Diamond Sword","277:0":"Diamond Shovel","278:0":"Diamond Pickaxe","279:0":"Diamond Axe","280:0":"Stick","281:0":"Bowl","282:0":"Mushroom Soup","283:0":"Gold Sword","284:0":"Gold Shovel","285:0":"Gold Pickaxe","286:0":"Gold Axe","287:0":"String","288:0":"Feather","289:0":"Gunpowder","290:0":"Wooden Hoe","291:0":"Stone Hoe","292:0":"Iron Hoe","293:0":"Diamond Hoe","294:0":"Gold Hoe","295:0":"Seeds","296:0":"Wheat","297:0":"Bread","298:0":"Leather Helmet","299:0":"Leather Chestplate", 		"300:0":"Leather Leggings","301:0":"Leather Boots","302:0":"Chainmail Helmet","303:0":"Chainmail Chestplate","304:0":"Chainmail Leggings","305:0":"Chainmail Boots","306:0":"Iron Helmet","307:0":"Iron Chestplate","308:0":"Iron Leggings","309:0":"Iron Boots","310:0":"Diamond Helmet","311:0":"Diamond Chestplate","312:0":"Diamond Leggings","313:0":"Diamond Boots","314:0":"Gold Helmet","315:0":"Gold Chestplate","316:0":"Gold Leggings","317:0":"Gold Boots","318:0":"Flint","319:0":"Raw Porkchop","320:0":"Cooked Porkchop","321:0":"Painting","323:0":"Sign","324:0":"Wooden Door","325:0":"Bucket","325:1":"Milk Bucket","325:8":"Water Bucket","325:10":"Lava Bucket","328:0":"Minecart","329:0":"Saddle","330:0":"Iron Door","331:0":"Redstone","332:0":"Snowball","334:0":"Leather","336:0":"Clay Brick","337:0":"Clay","338:0":"Sugar Cane","339:0":"Paper","340:0":"Book","341:0":"Slime Ball","344:0":"Egg","345:0":"Compass","347:0":"Clock","348:0":"Glowstone Dust", 		"351:0":"Ink Sack","351:1":"Rose Red","351:2":"Cactus Green","351:3":"Cocoa Beans","351:4":"Lapis Lazuli","351:5":"Purple Dye","351:6":"Cyan Dye","351:7":"Light Gray Dye","351:8":"Gray Dye","351:9":"Pink Dye","351:10":"Lime Dye","351:11":"Dandelion Yellow Dye","351:12":"Light Blue Dye","351:13":"Magenta Dye","351:14":"Orange Dye","351:15":"Bone Meal","352:0":"Bone","353:0":"Sugar","354:0":"Cake","355:0":"Bed","359:0":"Shears","360:0":"Melon","361:0":"Pumpkin Seeds","362:0":"Melon Seeds","363:0":"Raw Beef","364:0":"Steak","365:0":"Raw Chicken","366:0":"Cooked Chicken","383:10":"Spawn Chicken","383:11":"Spawn Cow","383:12":"Spawn Pig","383:13":"Spawn Sheep","391:0":"Carrot","392:0":"Potato","393:0":"Baked Potato","400:0":"Pumpkin Pie","405:0":"Nether Brick","406:0":"Nether Quartz","456:0":"Camera","457:0":"Beetroot","458:0":"Beetroot Seeds","459:0":"Beetroot Soup" 		}; 	if(IDs[id]) 		return IDs[id]; 	else 		return Item.getName(parseInt(id.split(":")[0]),parseInt(id.split(":")[2]),true).replace("item.","").replace("tile.",""); 	}  function InArray(arr1,arr2){ 	if(arr2.length==0) 		return false; 	for(var i=0;i<arr2.length;i++){ 		if(arr2[i][0]==arr1[0] && arr2[i][1]==arr1[1] && arr2[i][2]==arr1[2]) 			return true; 		} 	return false; 	}  function FindHighestY(x,z){ 	for(var y=parseInt(Player.getY())+64;y>0;y--){ 		if(Level.getTile(x,y,z)!=0) 			return y; 		} 	return 0; 	} 	 function IDinArray(arr1,arr2){ 	for(var i=0;i<arr2.length;i++){ 		if(arr2[i][0]==arr1[0] && arr2[i][1]==arr1[1]) 			return true; 		} 	return false; 	} 	 function Chances(p){ 	var rnd=Math.floor(Math.random()*101); 	if(rnd<p) 		return true; 	return false; 	}  var machineWindow=null; var closeButtonWindow=null; var playerWindow=null; function Machines(){ 	if(mBlocks.length==0) 		return; 	for(var i=0;i<mBlocks.length;i++){ 		if(Level.getTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2])==195){	//Grinder 			var sides=[[mBlocks[i][0],mBlocks[i][1]-1,mBlocks[i][2]],[mBlocks[i][0],mBlocks[i][1]+1,mBlocks[i][2]],[mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]-1],[mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]+1],[mBlocks[i][0]-1,mBlocks[i][1],mBlocks[i][2]],[mBlocks[i][0]+1,mBlocks[i][1],mBlocks[i][2]]]; 			var con=false; 			for(var j=0;j<6;j++){ 				if(InArray([sides[j][0],sides[j][1],sides[j][2]],poweredBlocks)){ 					con=true; 					break; 					} 				} 			if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][0]!=0 && con && mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]<64) 				mBlocksProgress[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]]+=0.5; 			else 				mBlocksProgress[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]]=0; 			if(mBlocksProgress[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]]==100){ 				if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]==0 || (mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]==grinded[mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][0]] && mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]<64)){ 					if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]==0){ 						mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]=grinded[mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][0]]; 						mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]=1; 						} 					else 						mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]++; 					if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][1]==1) 						mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][0]=0; 					mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][1]--; 					} 				mBlocksProgress[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]]=0; 				if(machineWindow!=null) 					ShowMachineGUI(mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]); 				} 			if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]!=0){ 				for(var j=2;j<6;j++){ 					if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==54 || Level.getTile(sides[j][0],sides[j][1],sides[j][2])==61 || Level.getTile(sides[j][0],sides[j][1],sides[j][2])==62){ 						var old=Level.getTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]); 						Level.setTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],54,0); 						Level.setChestSlot(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],0,mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2],0,1); 						if(MoveItems([mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]],[sides[j][0],sides[j][1],sides[j][2]],1)){ 							mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]--; 							if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]==0) 								mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]=0; 							} 						Level.setChestSlot(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],0,0); 						Level.setTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],old,0); 						break; 						} 					else if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==182){ 						var old=Level.getTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]); 						Level.setTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],54,0); 						Level.setChestSlot(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],0,mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2],0,1); 						Level.setTile(sides[j][0],sides[j][1],sides[j][2],181,0); 						if(MoveItems([mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]],FindChest(sides[j][0],sides[j][1],sides[j][2]),1)){ 							mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]--; 							if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]==0) 								mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]=0; 							} 						Level.setChestSlot(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],0,0); 						Level.setTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],old,0); 						Level.setTile(sides[j][0],sides[j][1],sides[j][2],182,0); 						break; 						} 					else if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==180){ 						sides=[[sides[j][0],sides[j][1]-1,sides[j][2]],[sides[j][0],sides[j][1]+1,sides[j][2]],[sides[j][0],sides[j][1],sides[j][2]-1],[sides[j][0],sides[j][1],sides[j][2]+1],[sides[j][0]-1,sides[j][1],sides[j][2]],[sides[j][0]+1,sides[j][1],sides[j][2]]]; 						var old=Level.getTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]); 						var cx,cy,cz; 						for(var k=0;k<6;k++){ 							if(Level.getTile(sides[k][0],sides[k][1],sides[k][2])==68 && Level.getSignText(sides[k][0],sides[k][1],sides[k][2],0)=="Barrel"){ 								cx=sides[k][0]; 								cy=sides[k][1]; 								cz=sides[k][2]; 								break; 								} 							} 						if(cx==cy) 							break; 						Level.setTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],54,0); 						Level.setChestSlot(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],0,mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2],0,1); 						if(MoveItems([mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]],[cx,cy,cz],1)){ 							mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]--; 							if(mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][3]==0) 								mBlocksSlots[mBlocks[i][0]+","+mBlocks[i][1]+","+mBlocks[i][2]][2]=0; 							} 						Level.setChestSlot(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],0,0); 						Level.setTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],old,0); 						break; 						} 					} 				} 			} 		if(Level.getTile(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2])==200){	//Drill 			var sides=[[mBlocks[i][0],mBlocks[i][1]-1,mBlocks[i][2]],[mBlocks[i][0],mBlocks[i][1]+1,mBlocks[i][2]],[mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]-1],[mBlocks[i][0],mBlocks[i][1],mBlocks[i][2]+1],[mBlocks[i][0]-1,mBlocks[i][1],mBlocks[i][2]],[mBlocks[i][0]+1,mBlocks[i][1],mBlocks[i][2]]]; 			var con=false; 			for(var j=0;j<6;j++){ 				if(InArray([sides[j][0],sides[j][1],sides[j][2]],poweredBlocks)){ 					con=true; 					break; 					} 				} 			if(con && (tickCounter==19 || tickCounter==39)){ 				for(var y=1;y<mBlocks[i][1]+1;y++){ 					if(Level.getTile(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2])==7){ 						mBlocks.splice(i,1); 						return; 						} 					else if(Level.getTile(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2])==0) 						Level.setTile(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2],201); 					else if(Level.getTile(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2])!=0 && Level.getTile(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2])!=201){ 						var blockID=[Level.getTile(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2]),Level.getData(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2]),1]; 						Level.destroyBlock(mBlocks[i][0],mBlocks[i][1]-y,mBlocks[i][2],false); 						blockID=GetCorrectBlock(blockID[0],blockID[1],blockID[2]); 						if(blockID[0]!=0) 							AutoOutput(mBlocks[i][0],mBlocks[i][1],mBlocks[i][2],blockID[0],blockID[1],blockID[2]); 						break; 						} 					} 				} 			} 		} 	}  function AutoOutput(x,y,z,id,dmg,amount){ 	var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 	var cx,cy,cz; 	for(var i=0;i<6;i++){ 		if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==54){ 			cx=sides[i][0]; 			cy=sides[i][1]; 			cz=sides[i][2]; 			var old=Level.getTile(x,y,z); 			Level.setTile(x,y,z,54); 			Level.setChestSlot(x,y,z,0,id,dmg,amount); 			MoveItems([x,y,z],[cx,cy,cz],amount); 			Level.setChestSlot(x,y,z,0,0); 			Level.setTile(x,y,z,old); 			break; 			} 		if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==182){ 			cx=sides[i][0]; 			cy=sides[i][1]; 			cz=sides[i][2]; 			var old=Level.getTile(x,y,z); 			Level.setTile(x,y,z,54); 			Level.setTile(cx,cy,cz,181); 			Level.setChestSlot(x,y,z,0,id,dmg,amount); 			MoveItems([x,y,z],FindChest(cx,cy,cz),amount); 			Level.setChestSlot(x,y,z,0,0); 			Level.setTile(cx,cy,cz,182); 			Level.setTile(x,y,z,old); 			break; 			} 		} 	if(cx==cy){ 		Level.dropItem(x,y+1,z,0,id,amount,dmg) 		} 	}  function GetCorrectBlock(id,dmg,amount){ 	var IDb={ 		8:0,9:0,10:0,11:0,18:0,19:0,20:0,30:0,31:0,32:0,51:0,79:0,92:0,102:0, 		1:4,2:3,16:263,21:351,43:44,56:264,59:295,60:3,62:61,63:323,68:323,73:331,74:331,78:332,82:337,83:338,89:348,104:360,105:361,141:391,142:392,244:458 		}; 	if(IDb[id]) 		id=IDb[id]; 	dmg=0; 	amount=1; 	if(id==331) 		amount=4; 	if(id==337) 		amount=4; 	if(id==348) 		amount=3; 	if(id==351){ 		amount=6; 		dmg=4; 		} 	return [id,dmg,amount]; 	}  function CheckTheWires(){ 	if(pBlocks.length>0){ 		for(var i=0;i<pBlocks.length;i++){ 			if(Level.getTile(pBlocks[i][0],pBlocks[i][1],pBlocks[i][2])==193)	//Solar panel 				PowerDistribution(pBlocks[i][0],pBlocks[i][1],pBlocks[i][2],true); 			if(Level.getTile(pBlocks[i][0],pBlocks[i][1],pBlocks[i][2])==194)	//Wire 				PowerDistribution(pBlocks[i][0],pBlocks[i][1],pBlocks[i][2],false); 			var sides=[[pBlocks[i][0],pBlocks[i][1]-1,pBlocks[i][2]],[pBlocks[i][0],pBlocks[i][1]+1,pBlocks[i][2]],[pBlocks[i][0],pBlocks[i][1],pBlocks[i][2]-1],[pBlocks[i][0],pBlocks[i][1],pBlocks[i][2]+1],[pBlocks[i][0]-1,pBlocks[i][1],pBlocks[i][2]],[pBlocks[i][0]+1,pBlocks[i][1],pBlocks[i][2]]]; 			for(var j=0;j<6;j++){ 				if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==193 || Level.getTile(sides[j][0],sides[j][1],sides[j][2])==194){ 					if(!InArray([sides[j][0],sides[j][1],sides[j][2]],pBlocks)) 						pBlocks.push([sides[j][0],sides[j][1],sides[j][2]]); 					} 				} 			} 		} 	}  function PlaceBlock(x,y,z,side,id,dmg){ 	var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 	Level.setTile(sides[side][0],sides[side][1],sides[side][2],id,dmg); 	if(Player.getCarriedItemCount()>1) 		Entity.setCarriedItem(Player.getEntity(),Player.getCarriedItem(),Player.getCarriedItemCount()-1,Player.getCarriedItemData()); 	else{ 		for(var i=0;i<9;i++){ 			if(Player.getInventorySlot(i)==Player.getCarriedItem() && Player.getInventorySlotData(i)==Player.getCarriedItemData() && Player.getInventorySlotCount(i)==Player.getCarriedItemCount()){ 				Player.clearInventorySlot(i); 				break; 				} 			} 		} 	}  function PowerDistribution(x,y,z,bool){ 	if(bool && !InArray([x,y,z],poweredBlocks)) 		poweredBlocks.push([x,y,z]); 	else{ 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		for(var i=0;i<6;i++){ 			if(InArray([sides[i][0],sides[i][1],sides[i][2]],poweredBlocks) && !InArray([x,y,z],poweredBlocks)){ 				poweredBlocks.push([x,y,z]); 				break; 				} 			} 		} 	}  function Generator(x,y,z,id,dmg,amount){ 	var waterPos=[]; 	var lavaPos=[]; 	if(id==4 || id==1 || id==49){ 		var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		var isWater=false; 		var isLava=false; 		for(var i=2;i<6;i++){ 			if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==11 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==10){ 				isLava=true; 				lavaPos=[sides[i][0],sides[i][1],sides[i][2]]; 				} 			else if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==9 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==8){ 				isWater=true; 				waterPos=[sides[i][0],sides[i][1],sides[i][2]]; 				} 			} 		if(!isWater || !isLava) 			return; 		} 	if(Level.getTile(x,y+1,z)==54){ 		var old=Level.getTile(x,y,z); 		Level.setTile(x,y,z,54); 		Level.setChestSlot(x,y,z,0,id,dmg,amount); 		MoveItems([x,y,z],[x,y+1,z],amount); 		if(id==1) 			Level.setTile(waterPos[0],waterPos[1],waterPos[2],0); 		if(id==49){ 			Level.setTile(waterPos[0],waterPos[1],waterPos[2],0); 			Level.setTile(lavaPos[0],lavaPos[1],lavaPos[2],0); 			} 		Level.setChestSlot(x,y,z,0,0); 		Level.setTile(x,y,z,old); 		} 	else if(Level.getTile(x,y+1,z)==61 || Level.getTile(x,y+1,z)==62){ 		var old=Level.getTile(x,y,z); 		Level.setTile(x,y,z,54); 		Level.setChestSlot(x,y,z,0,id,dmg,amount); 		MoveItems([x,y,z],[x,y+1,z],amount); 		if(id==1) 			Level.setTile(waterPos[0],waterPos[1],waterPos[2],0); 		if(id==49){ 			Level.setTile(waterPos[0],waterPos[1],waterPos[2],0); 			Level.setTile(lavaPos[0],lavaPos[1],lavaPos[2],0); 			} 		Level.setChestSlot(x,y,z,0,0); 		Level.setTile(x,y,z,old); 		} 	else if(Level.getTile(x,y+1,z)==180){ 		var sides=[[x,y,z],[x,y+2,z],[x,y+1,z-1],[x,y+1,z+1],[x-1,y+1,z],[x+1,y+1,z]]; 		var old=Level.getTile(x,y,z); 		Level.setTile(x,y,z,54); 		Level.setChestSlot(x,y,z,0,id,dmg,amount); 		for(var i=0;i<6;i++){ 			if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==68 && Level.getSignText(sides[i][0],sides[i][1],sides[i][2],0)=="Barrel"){ 				MoveItems([x,y,z],[sides[i][0],sides[i][1],sides[i][2]],amount); 				net.zhuoweizhang.mcpelauncher.ScriptManager.nativeExtinguishFire(sides[i][0],sides[i][1],sides[i][2],0); 				if(id==1) 					Level.setTile(waterPos[0],waterPos[1],waterPos[2],0); 				if(id==49){ 					Level.setTile(waterPos[0],waterPos[1],waterPos[2],0); 					Level.setTile(lavaPos[0],lavaPos[1],lavaPos[2],0); 					} 				break; 				} 			} 		Level.setChestSlot(x,y,z,0,0); 		Level.setTile(x,y,z,old); 		} 	else if(Level.getTile(x,y+1,z)==182){ 		var old=Level.getTile(x,y,z); 		Level.setTile(x,y,z,54); 		Level.setTile(x,y+1,z,181); 		Level.setChestSlot(x,y,z,0,id,dmg,amount); 		MoveItems([x,y,z],FindChest(x,y+1,z),amount); 		Level.setChestSlot(x,y,z,0,0); 		Level.setTile(x,y,z,old); 		Level.setTile(x,y+1,z,182); 		} 	return; 	}  function Farmer(x,y,z,range){ 	//if(Level.getTile(x,y+1,z)!=8 && Level.getTile(x,y+1,z)!=9) 	//	return; 	var isChest=false; 	var powered=false; 	var cx,cy,cz; 	var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 	for(var i=0;i<6;i++){ 		if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==54){ 			cx=sides[i][0]; 			cy=sides[i][1]; 			cz=sides[i][2]; 			isChest=true; 			break; 			} 		} 	if(!isChest) 		return; 	for(var i=0;i<6;i++){ 		if(InArray([sides[i][0],sides[i][1],sides[i][2]],poweredBlocks)){ 			powered=true; 			break; 			} 		} 	if(!powered) 		return; 	var inRange=[]; 	for(var i=-range;i<range+1;i++){ 		for(var j=-range;j<range+1;j++) 			inRange.push([x+i,y+2,z+j]); 		} 	var planted={295:59,391:141,392:142,458:244}; 	var planted2={59:295,141:391,142:392,244:458}; 	var product={59:296,141:391,142:392,244:457}; 	for(var i=0;i<inRange.length;i++){ 		if(Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])==0 && Level.getTile(inRange[i][0],inRange[i][1]-1,inRange[i][2])==60){ 			for(var j=0;j<27;j++){ 				if(Level.getChestSlot(cx,cy,cz,j)==295 || Level.getChestSlot(cx,cy,cz,j)==391 || Level.getChestSlot(cx,cy,cz,j)==392 || Level.getChestSlot(cx,cy,cz,j)==458){ 					Level.setTile(inRange[i][0],inRange[i][1],inRange[i][2],planted[Level.getChestSlot(cx,cy,cz,j)],0); 					if(Level.getChestSlotCount(cx,cy,cz,j)>1) 						Level.setChestSlot(cx,cy,cz,j,Level.getChestSlot(cx,cy,cz,j),0,Level.getChestSlotCount(cx,cy,cz,j)-1); 					else 						Level.setChestSlot(cx,cy,cz,j,0); 					break; 					} 				} 			return; 			} 		if(Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])==0 && (Level.getTile(inRange[i][0],inRange[i][1]-1,inRange[i][2])==2 || Level.getTile(inRange[i][0],inRange[i][1]-1,inRange[i][2])==3)){ 			Level.setTile(inRange[i][0],inRange[i][1]-1,inRange[i][2],60,6); 			return; 			} 		if((Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])==59 || Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])==141 || Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])==142 || Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])==244) && Level.getData(inRange[i][0],inRange[i][1],inRange[i][2])==7){ 			var rnd=Math.floor(Math.random()*3)+1; 			var old=Level.getTile(x,y,z); 			Level.setTile(x,y,z,54); 			Level.setChestSlot(x,y,z,0,planted2[Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])],0,rnd); 			MoveItems([x,y,z],[cx,cy,cz],rnd); 			Level.setChestSlot(x,y,z,0,product[Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2])],0,1); 			MoveItems([x,y,z],[cx,cy,cz],1); 			Level.setChestSlot(x,y,z,0,0); 			Level.setTile(x,y,z,old); 			Level.destroyBlock(inRange[i][0],inRange[i][1],inRange[i][2],false); 			return; 			} 		} 	}  function TreeFarmer(x,y,z,range){ 	var isChest=false; 	var powered=false; 	var cx,cy,cz; 	var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 	for(var i=0;i<6;i++){ 		if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==54){ 			cx=sides[i][0]; 			cy=sides[i][1]; 			cz=sides[i][2]; 			isChest=true; 			break; 			} 		} 	if(!isChest) 		return; 	for(var i=0;i<6;i++){ 		if(InArray([sides[i][0],sides[i][1],sides[i][2]],poweredBlocks)){ 			powered=true; 			break; 			} 		} 	if(!powered) 		return; 	var inRange=[]; 	for(var k=0;k<8;k++){ 		for(var j=-range;j<range+1;j++){ 			for(var i=-range;i<range+1;i++) 				inRange.push([x+i,y+8-k,z+j]); 			} 		} 	for(var i=0;i<inRange.length;i++){ 		var id=Level.getTile(inRange[i][0],inRange[i][1],inRange[i][2]); 		var dmg=Level.getData(inRange[i][0],inRange[i][1],inRange[i][2]); 		if(id==0 && (Level.getTile(inRange[i][0],inRange[i][1]-1,inRange[i][2])==2 || Level.getTile(inRange[i][0],inRange[i][1]-1,inRange[i][2])==3)){ 			for(var j=0;j<27;j++){ 				if(Level.getChestSlot(cx,cy,cz,j)==6){ 					Level.setTile(inRange[i][0],inRange[i][1],inRange[i][2],Level.getChestSlot(cx,cy,cz,j),Level.getChestSlotData(cx,cy,cz,j)); 					if(Level.getChestSlotCount(cx,cy,cz,j)>1) 						Level.setChestSlot(cx,cy,cz,j,Level.getChestSlot(cx,cy,cz,j),Level.getChestSlotData(cx,cy,cz,j),Level.getChestSlotCount(cx,cy,cz,j)-1); 					else 						Level.setChestSlot(cx,cy,cz,j,0); 					break; 					} 				} 			return; 			} 		if(id==18){ 			var sides=[[inRange[i][0],inRange[i][1],inRange[i][2]],[inRange[i][0],inRange[i][1]-1,inRange[i][2]],[inRange[i][0],inRange[i][1]+1,inRange[i][2]],[inRange[i][0],inRange[i][1],inRange[i][2]-1],[inRange[i][0],inRange[i][1],inRange[i][2]+1],[inRange[i][0]-1,inRange[i][1],inRange[i][2]],[inRange[i][0]+1,inRange[i][1],inRange[i][2]]]; 			for(var j=0;j<6;j++){ 				if(Chances(5)){ 					var old=Level.getTile(x,y,z); 					Level.setTile(x,y,z,54); 					Level.setChestSlot(x,y,z,0,260,0,1); 					MoveItems([x,y,z],[cx,cy,cz],1); 					Level.setChestSlot(x,y,z,0,0); 					Level.setTile(x,y,z,old); 					} 				if(Chances(20)){ 					var old=Level.getTile(x,y,z); 					Level.setTile(x,y,z,54); 					Level.setChestSlot(x,y,z,0,6,Level.getData(sides[j][0],sides[j][1],sides[j][2])-7,1); 					MoveItems([x,y,z],[cx,cy,cz],1); 					Level.setChestSlot(x,y,z,0,0); 					Level.setTile(x,y,z,old); 					} 				if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==18) 					Level.destroyBlock(sides[j][0],sides[j][1],sides[j][2],false); 				} 			return; 			} 		else if(id==17){ 			var old=Level.getTile(x,y,z); 			Level.setTile(x,y,z,54); 			Level.setChestSlot(x,y,z,0,17,Level.getData(sides[j][0],sides[j][1],sides[j][2]),1); 			MoveItems([x,y,z],[cx,cy,cz],1); 			Level.setChestSlot(x,y,z,0,0); 			Level.setTile(x,y,z,old); 			Level.destroyBlock(inRange[i][0],inRange[i][1],inRange[i][2],false); 			return; 			} 		} 	}  function FindChest(x,y,z){ 	var sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 	var side=[x,y,z,0]; 	var passed=[[x,y,z]]; 	var routes=[[x,y,z]]; 	for(var i=0;i<6;i++){ 		if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==182) 			routes.push([sides[i][0],sides[i][1],sides[i][2]]); 		} 	if(routes.length>1){ 		var rnd=Math.floor(Math.floor(Math.random()*(routes.length-1))+1); 		x=routes[rnd][0]; 		y=routes[rnd][1]; 		z=routes[rnd][2]; 		} 	else 		return side; 	while(passed[passed.length-1][0]!=x || passed[passed.length-1][1]!=y || passed[passed.length-1][2]!=z){ 		sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		routes=[[x,y,z,0]]; 		for(var i=0;i<6;i++){ 			sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 			if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==54) 				routes.push([sides[i][0],sides[i][1],sides[i][2],i]); 			else if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==195){ 				if(!InArray([sides[i][0],sides[i][1],sides[i][2]],mBlocks)){ 					mBlocks.push([sides[i][0],sides[i][1],sides[i][2]]); 					if(!mBlocksSlots[sides[i][0]+","+sides[i][1]+","+sides[i][2]]) 						mBlocksSlots[sides[i][0]+","+sides[i][1]+","+sides[i][2]]=[0,0,0,0]; 					if(!mBlocksProgress[sides[i][0]+","+sides[i][1]+","+sides[i][2]]) 						mBlocksProgress[sides[i][0]+","+sides[i][1]+","+sides[i][2]]=0; 					} 				routes.push([sides[i][0],sides[i][1],sides[i][2],i]); 				} 			else if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==61 || Level.getTile(sides[i][0],sides[i][1],sides[i][2])==62) 				routes.push([sides[i][0],sides[i][1],sides[i][2],i]); 			else if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==180){ 				sides=[[sides[i][0],sides[i][1]-1,sides[i][2]],[sides[i][0],sides[i][1]+1,sides[i][2]],[sides[i][0],sides[i][1],sides[i][2]-1],[sides[i][0],sides[i][1],sides[i][2]+1],[sides[i][0]-1,sides[i][1],sides[i][2]],[sides[i][0]+1,sides[i][1],sides[i][2]]]; 				for(var j=0;j<6;j++){ 					if(Level.getTile(sides[j][0],sides[j][1],sides[j][2])==68 && Level.getSignText(sides[j][0],sides[j][1],sides[j][2],0)=="Barrel"){ 						routes.push([sides[j][0],sides[j][1],sides[j][2],j]); 						break; 						} 					} 				} 			} 		if(routes.length>1) 			return routes[Math.floor(Math.random()*(routes.length-1))+1]; 		passed.push([x,y,z]); 		sides=[[x,y-1,z],[x,y+1,z],[x,y,z-1],[x,y,z+1],[x-1,y,z],[x+1,y,z]]; 		routes=[[x,y,z]]; 		for(var i=0;i<6;i++){ 			if(Level.getTile(sides[i][0],sides[i][1],sides[i][2])==182) 				routes.push([sides[i][0],sides[i][1],sides[i][2]]); 			} 		if(routes.length>1){ 			var rnd=Math.floor(Math.floor(Math.random()*(routes.length-1))+1); 			x=routes[rnd][0]; 			y=routes[rnd][1]; 			z=routes[rnd][2]; 			} 		else 			return side; 		if(InArray([x,y,z],passed)) 			return side; 		} 	return side; 	}  function MoveItems(from,to,amount){ 	if(Level.getTile(to[0],to[1],to[2])!=54 && Level.getTile(to[0],to[1],to[2])!=195 && Level.getTile(to[0],to[1],to[2])!=61 && Level.getTile(to[0],to[1],to[2])!=62 && Level.getTile(to[0],to[1],to[2])!=68) 		return; 	var ChestEmpty=true; 	if(Level.getTile(from[0],from[1],from[2])==54){ 		for(var i=0;i<27;i++){ 			if(Level.getChestSlot(from[0],from[1],from[2],i)!=0){ 				ChestEmpty=false; 				break; 				} 			} 		} 	if(Level.getTile(from[0],from[1],from[2])==61 || Level.getTile(from[0],from[1],from[2])==62){ 		if(Level.getFurnaceSlot(from[0],from[1],from[2],2)!=0) 			ChestEmpty=false; 		} 	if(Level.getTile(from[0],from[1],from[2])==68 && Level.getSignText(from[0],from[1],from[2],0)=="Barrel"){ 		if(Level.getSignText(from[0],from[1],from[2],3)!="Barrel") 			ChestEmpty=false; 		} 	if(ChestEmpty) 		return;  	var buffer=[0,0,1]; 	if(Level.getTile(from[0],from[1],from[2])==54){ 		for(var i=0;i<27;i++){ 			if(Level.getChestSlot(from[0],from[1],from[2],i)!=0){ 				buffer=[Level.getChestSlot(from[0],from[1],from[2],i),Level.getChestSlotData(from[0],from[1],from[2],i),1]; 				if(Level.getChestSlotCount(from[0],from[1],from[2],i)>amount){ 					Level.setChestSlot(from[0],from[1],from[2],i,buffer[0],buffer[1],Level.getChestSlotCount(from[0],from[1],from[2],i)-amount); 					buffer[2]=amount; 					} 				else{ 					buffer[2]=Level.getChestSlotCount(from[0],from[1],from[2],i); 					Level.setChestSlot(from[0],from[1],from[2],i,0); 					} 				break; 				} 			} 		} 	if(Level.getTile(from[0],from[1],from[2])==61 || Level.getTile(from[0],from[1],from[2])==62){ 		buffer=[Level.getFurnaceSlot(from[0],from[1],from[2],2),Level.getFurnaceSlotData(from[0],from[1],from[2],2),1]; 		if(Level.getFurnaceSlotCount(from[0],from[1],from[2],2)>amount){ 			Level.setFurnaceSlot(from[0],from[1],from[2],2,buffer[0],buffer[1],Level.getFurnaceSlotCount(from[0],from[1],from[2],3)-amount) 			buffer[2]=amount; 			} 		else{ 			buffer[2]=Level.getFurnaceSlotCount(from[0],from[1],from[2],2); 			Level.setFurnaceSlot(from[0],from[1],from[2],2,0) 			} 		} 	if(Level.getTile(from[0],from[1],from[2])==68){ 		buffer=[Level.getSignText(from[0],from[1],from[2],3).split(":")[0],Level.getSignText(from[0],from[1],from[2],3).split(":")[1],1]; 		var itemCount=64*parseInt(Level.getSignText(from[0],from[1],from[2],2).split("x")[0])+parseInt(Level.getSignText(from[0],from[1],from[2],2).split("+")[1]); 		if(itemCount>amount){ 			itemCount-=amount; 			Level.setSignText(from[0],from[1],from[2],2,parseInt(itemCount/64)+"x64+"+(itemCount-parseInt(itemCount/64)*64)); 			buffer[2]=amount; 			} 		else{ 			buffer[2]=amount; 			Level.setSignText(from[0],from[1],from[2],1," "); 			Level.setSignText(from[0],from[1],from[2],2," "); 			Level.setSignText(from[0],from[1],from[2],3,"Barrel"); 			} 		} 	var ChestHasSpace=false; 	var free=0; 	if(Level.getTile(to[0],to[1],to[2])==54){ 		for(var i=0;i<27;i++){ 			if(Level.getChestSlot(to[0],to[1],to[2],i)==0) 				free+=64; 			else if(Level.getChestSlot(to[0],to[1],to[2],i)==buffer[0] && Level.getChestSlotCount(to[0],to[1],to[2],i)<64 && Level.getChestSlotData(to[0],to[1],to[2],i)==buffer[1]) 				free+=64-Level.getChestSlotCount(to[0],to[1],to[2],i); 			} 		} 	if(Level.getTile(to[0],to[1],to[2])==195 && to[3]<2){ 		if(mBlocksSlots[to[0]+","+to[1]+","+to[2]][0]==0) 			free+=64; 		else if(mBlocksSlots[to[0]+","+to[1]+","+to[2]][0]==buffer[0] && mBlocksSlots[to[0]+","+to[1]+","+to[2]][1]<64) 			free+=64-mBlocksSlots[to[0]+","+to[1]+","+to[2]][1]; 		} 	if(Level.getTile(to[0],to[1],to[2])==61 || Level.getTile(to[0],to[1],to[2])==62){ 		if(to[3]>1){ 			if(Level.getFurnaceSlot(to[0],to[1],to[2],1)==0) 				free=64; 			else if(Level.getFurnaceSlot(to[0],to[1],to[2],1)==buffer[0] && Level.getFurnaceSlotCount(to[0],to[1],to[2],1)<64 && Level.getFurnaceSlotData(to[0],to[1],to[2],1)==buffer[1]) 				free=64-Level.getFurnaceSlotCount(to[0],to[1],to[2],1); 			} 		else{ 			if(Level.getFurnaceSlot(to[0],to[1],to[2],0)==0) 				free=64; 			else if(Level.getFurnaceSlot(to[0],to[1],to[2],0)==buffer[0] && Level.getFurnaceSlotCount(to[0],to[1],to[2],0)<64 && Level.getFurnaceSlotData(to[0],to[1],to[2],0)==buffer[1]) 				free=64-Level.getFurnaceSlotCount(to[0],to[1],to[2],0); 			} 		} 	if(Level.getTile(to[0],to[1],to[2])==68){ 		if(Level.getSignText(to[0],to[1],to[2],3)=="Barrel") 			free=4096; 		else if(parseInt(Level.getSignText(to[0],to[1],to[2],3).split(":")[0])==buffer[0] && 64*parseInt(Level.getSignText(to[0],to[1],to[2],2).split("x")[0])+parseInt(Level.getSignText(to[0],to[1],to[2],2).split("+")[1])<4096 && parseInt(Level.getSignText(to[0],to[1],to[2],3).split(":")[1])==buffer[1]) 			free=4096-64*parseInt(Level.getSignText(to[0],to[1],to[2],2).split("x")[0])+parseInt(Level.getSignText(to[0],to[1],to[2],2).split("+")[1]); 		} 	if(buffer[2]<=free) 		ChestHasSpace=true; 	else 		ChestHasSpace=false; 	if(ChestHasSpace){ 		if(Level.getTile(to[0],to[1],to[2])==54){ 			for(var i=0;i<27;i++){ 				var c=Level.getChestSlotCount(to[0],to[1],to[2],i); 				if(Level.getChestSlot(to[0],to[1],to[2],i)==0 || (Level.getChestSlot(to[0],to[1],to[2],i)==buffer[0] && c<64 && Level.getChestSlotData(to[0],to[1],to[2],i)==buffer[1])){ 					if(buffer[2]<64-c){ 						Level.setChestSlot(to[0],to[1],to[2],i,buffer[0],buffer[1],Level.getChestSlotCount(to[0],to[1],to[2],i)+buffer[2]); 						break; 						} 					else{ 						Level.setChestSlot(to[0],to[1],to[2],i,buffer[0],buffer[1],64); 						buffer[2]-=64-c; 						} 					} 				} 			} 		if(Level.getTile(to[0],to[1],to[2])==195 && to[3]<2){ 			var c=mBlocksSlots[to[0]+","+to[1]+","+to[2]][1]; 			if(mBlocksSlots[to[0]+","+to[1]+","+to[2]][0]==0 || (mBlocksSlots[to[0]+","+to[1]+","+to[2]][0]==buffer[0] && c<64)){ 				if(buffer[2]<64-c){ 					mBlocksSlots[to[0]+","+to[1]+","+to[2]][0]=buffer[0]; 					mBlocksSlots[to[0]+","+to[1]+","+to[2]][1]+=buffer[2]; 					if(machineWindow!=null) 						ShowMachineGUI(to[0]+","+to[1]+","+to[2]); 					} 				else{ 					mBlocksSlots[to[0]+","+to[1]+","+to[2]][0]=buffer[0]; 					mBlocksSlots[to[0]+","+to[1]+","+to[2]][1]=64; 					buffer[2]-=64-c; 					if(machineWindow!=null) 						ShowMachineGUI(to[0]+","+to[1]+","+to[2]); 					} 				} 			} 		if(Level.getTile(to[0],to[1],to[2])==61 || Level.getTile(to[0],to[1],to[2])==62){ 			if(to[3]>1){ 				var c=Level.getFurnaceSlotCount(to[0],to[1],to[2],1); 				if(Level.getFurnaceSlot(to[0],to[1],to[2],1)==0 || (Level.getFurnaceSlot(to[0],to[1],to[2],1)==buffer[0] && c<64 && Level.getFurnaceSlotData(to[0],to[1],to[2],1)==buffer[1])){ 					if(buffer[2]<64-c) 						Level.setFurnaceSlot(to[0],to[1],to[2],1,buffer[0],buffer[1],Level.getFurnaceSlotCount(to[0],to[1],to[2],1)+buffer[2]) 					else{ 						Level.setFurnaceSlot(to[0],to[1],to[2],1,buffer[0],buffer[1],64) 						buffer[2]-=64-c; 						} 					} 				} 			else{ 				var c=Level.getFurnaceSlotCount(to[0],to[1],to[2],0); 				if(Level.getFurnaceSlot(to[0],to[1],to[2],0)==0 || (Level.getFurnaceSlot(to[0],to[1],to[2],0)==buffer[0] && c<64 && Level.getFurnaceSlotData(to[0],to[1],to[2],0)==buffer[1])){ 					if(buffer[2]<64-c) 						Level.setFurnaceSlot(to[0],to[1],to[2],0,buffer[0],buffer[1],Level.getFurnaceSlotCount(to[0],to[1],to[2],0)+buffer[2]) 					else{ 						Level.setFurnaceSlot(to[0],to[1],to[2],0,buffer[0],buffer[1],64) 						buffer[2]-=64-c; 						} 					} 				} 			} 		if(Level.getTile(to[0],to[1],to[2])==68){ 			if(Level.getSignText(to[0],to[1],to[2],3)=="Barrel") 				c=0; 			else 				var c=64*parseInt(Level.getSignText(to[0],to[1],to[2],2).split("x")[0])+parseInt(Level.getSignText(to[0],to[1],to[2],2).split("+")[1]); 			if(Level.getSignText(to[0],to[1],to[2],3)=="Barrel" || (parseInt(Level.getSignText(to[0],to[1],to[2],3).split(":")[0])==buffer[0] && c<4096 && parseInt(Level.getSignText(to[0],to[1],to[2],3).split(":")[1])==buffer[1])){ 				if(buffer[2]<4096-c){ 					var cc=c+buffer[2]; 					Level.setSignText(to[0],to[1],to[2],1,GetItemBlockName(buffer[0]+":"+buffer[1])); 					Level.setSignText(to[0],to[1],to[2],3,buffer[0]+":"+buffer[1]); 					Level.setSignText(to[0],to[1],to[2],2,parseInt(cc/64)+"x64+"+(cc-parseInt(cc/64)*64)); 					} 				else{ 					Level.setSignText(to[0],to[1],to[2],1,GetItemBlockName(buffer[0]+":"+buffer[1])); 					Level.setSignText(to[0],to[1],to[2],3,buffer[0]+":"+buffer[1]); 					Level.setSignText(to[0],to[1],to[2],2,"64x64+0") 					buffer[2]-=4096-c; 					} 				} 			} 		} 	else/* if(InArray(from,wrenchEx))*/{ 		if(Level.getTile(from[0],from[1],from[2])==54){ 			for(var i=0;i<27;i++){ 				var c=Level.getChestSlotCount(from[0],from[1],from[2],i); 				if(Level.getChestSlot(from[0],from[1],from[2],i)==0 || (Level.getChestSlot(from[0],from[1],from[2],i)==buffer[0] && c<64 && Level.getChestSlotData(from[0],from[1],from[2],i)==buffer[1])){ 					if(buffer[2]<64-c){ 						Level.setChestSlot(from[0],from[1],from[2],i,buffer[0],buffer[1],Level.getChestSlotCount(from[0],from[1],from[2],i)+buffer[2]); 						break; 						} 					else{ 						Level.setChestSlot(from[0],from[1],from[2],i,buffer[0],buffer[1],64); 						buffer[2]-=64-c; 						} 					} 				} 			} 		if(Level.getTile(from[0],from[1],from[2])==61 || Level.getTile(from[0],from[1],from[2])==62){ 			var c=Level.getFurnaceSlotCount(from[0],from[1],from[2],2); 			if(Level.getFurnaceSlot(from[0],from[1],from[2],2)==0 || (Level.getFurnaceSlot(from[0],from[1],from[2],2)==buffer[0] && c<64 && Level.getFurnaceSlotData(to[0],to[1],to[2],2)==buffer[1])){ 				if(buffer[2]<64-c) 					Level.setFurnaceSlot(from[0],from[1],from[2],2,buffer[0],buffer[1],Level.getFurnaceSlotCount(from[0],from[1],from[2],3)+buffer[2]) 				else{ 					Level.setFurnaceSlot(from[0],from[1],from[2],2,buffer[0],buffer[1],64) 					buffer[2]-=64-c; 					} 				} 			} 		if(Level.getTile(from[0],from[1],from[2])==68){ 			var c=64*parseInt(Level.getSignText(from[0],from[1],from[2],2).split("x")[0])+parseInt(Level.getSignText(from[0],from[1],from[2],2).split("+")[1]); 			if(Level.getSignText(from[0],from[1],from[2],3)=="Barrel" || (parseInt(Level.getSignText(from[0],from[1],from[2],3).split(":")[0])==buffer[0] && c<4096 && parseInt(Level.getSignText(from[0],from[1],from[2],3).split(":")[1])==buffer[1])){ 				if(buffer[2]<4096-c){ 					var cc=c+buffer[2]; 					Level.setSignText(from[0],from[1