forked from tombailey/McPeScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
XYZ-yaw-pitch-GUI.js
56 lines (52 loc) · 1.46 KB
/
XYZ-yaw-pitch-GUI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var textview;
var ctx;
var simpleGUI;
function getXYZ() {
if(ctx!=null) {
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try{
if(textview != null) {
textview.setText("X: " + Math.round(Player.getX()) + " , Y: " + Math.round(Player.getY()) + " , Z: " + Math.round(Player.getZ()) + "\nYaw: " + Math.round(Player.getYaw()%360) + ", Pitch: " + Math.round(Player.getPitch()));
}
}catch(err){
//print("Error: "+err); //will cause spam of dialogue boxes because of modTick
}
}}));
}
}
function newLevel(){
ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try{
simpleGUI = new android.widget.PopupWindow();
var layout = new android.widget.RelativeLayout(ctx);
textview = new android.widget.TextView(ctx);
textview.setTextColor(android.graphics.Color.WHITE);
getXYZ();
layout.addView(textview);
simpleGUI.setContentView(layout);
simpleGUI.setWidth(400);
simpleGUI.setHeight(60);
simpleGUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0);
}catch(err){
print("Error: "+err);
}
} }));
}
function modTick() {
getXYZ();
}
function leaveGame(){
if(ctx!=null) {
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try{
if(simpleGUI != null) {
simpleGUI.dismiss();
simpleGUI = null;
}
}catch(err){
print("Error: "+err);
}
}}));
}
}