forked from beatzunknown/ModPE_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathontouch_alt.js
More file actions
95 lines (67 loc) · 2.12 KB
/
ontouch_alt.js
File metadata and controls
95 lines (67 loc) · 2.12 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var bowshot;
var GUI;
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
var start = false;
function newLevel(){
ctx.runOnUiThread(new java.lang.Runnable(){
run: function(){
try{
GUI = new android.widget.PopupWindow();
var layout = new android.widget.LinearLayout(ctx);
var btn = new android.widget.Button(ctx);
btn.setText("x");
layout.addView(btn);
GUI.setContentView(layout);
GUI.setHeight(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
GUI.setWidth(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.BOTTOM | android.view.Gravity.RIGHT, 0, 450);
btn.onTouchListener(new android.view.View.OnTouchListener({
onTouch: function(view, event){
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
bowshot = 1;
break;
case MotionEvent.ACTION_UP:
bowshot = 0;
break;
}
}
}));
} catch (e){
print ("Error: "+e)
}
}});
}
function leaveGame(){
ctx.runOnUiThread(new java.lang.Runnable(){
run: function(){
if(GUI != null){
GUI.dismiss();
}
}
});
}
function modTick() {
if(bowshot==1&&getPitch(getPlayerEnt())<40){
var playerYaw = Entity.getYaw(Player.getEntity());
var playerPitch = Entity.getPitch(Player.getEntity());
velY = Math.sin((playerPitch - 180) / 180 * Math.PI);
velX = Math.sin(playerYaw / 180 * Math.PI) * Math.cos((playerPitch - 180) / 180 * Math.PI);
velZ = -1 * Math.cos(playerYaw / 180 * Math.PI) * Math.cos((playerPitch - 180) / 180 * Math.PI);
tnt = Level.spawnMob(Player.getX(),Player.getY()+1,Player.getZ(),81);
setVelX(tnt,velX);
setVelY(tnt,velY);
setVelZ(tnt,velZ);
}
else if(bowshot==1&&getPitch(getPlayerEnt())>40){
var Yaw = Entity.getYaw(Player.getEntity());
var Pitch = Entity.getPitch(Player.getEntity());
velY = Math.sin((Pitch - 180) / 180 * Math.PI);
velX = Math.sin(Yaw / 180 * Math.PI) * Math.cos((Pitch - 180) / 180 * Math.PI);
velZ = -1 * Math.cos(Yaw / 180 * Math.PI) * Math.cos((Pitch - 180) / 180 * Math.PI);
tnt = Level.spawnMob(Player.getX()+1,Player.getY(),Player.getZ(),80);
setVelX(tnt,velX);
setVelY(tnt,velY);
setVelZ(tnt,velZ);
}
}