-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVertex Client PE - Addon Library.js
199 lines (171 loc) · 6.31 KB
/
Vertex Client PE - Addon Library.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/**
* Library made by peacestorm
* © 2016-2017
*/
/**
* PART 1 OF THE FUNCTION LIBRARY (DON'T EDIT)
*/
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
var Launcher = {
isBlockLauncher: function() {
return (ctx.getPackageName() == "net.zhuoweizhang.mcpelauncher" || ctx.getPackageName() == "net.zhuoweizhang.mcpelauncher.pro");
},
isToolbox: function() {
return ctx.getPackageName() == "io.mrarm.mctoolbox";
},
isMcpeMaster: function() {
return ctx.getPackageName() == "com.mcbox.pesdkb.mcpelauncher";
}
};
function Song(songTitle, songArtist, songUrl, songGenre) {
this.title = songTitle || "Unknown";
this.artist = songArtist || "Unknown";
this.genre = songGenre || "Unknown";
this.url = songUrl;
}
/**
* YOUR ADDON CONTENT
*/
const ADDON_NAME = "Example addon"; //Your addon's name
const ADDON_DESC = "Adds example modules into Vertex Client PE."; //Your addon's description
const ADDON_AUTHOR = "Xx_TheLegend27_xX"; //Your addon's author (type your name here)
const ADDON_VERSION = "1.0"; //Your addon's version
const TARGET_VERSION = "2.4"; //Your addon's target Vertex Client PE version (in this case we use Vertex Client PE v2.4)
var modules = [];
var songs = [];
var tiles = [];
const Category = {
COMBAT: 0,
WORLD: 1,
MOVEMENT: 2,
PLAYER: 3,
MISC: 4
}
/**
* CUSTOM MODULES
*/
/*
var exampleModule = {
name: "Example toggleable module",
desc: "Example description.",
category: Category.MOVEMENT,
type: "Mod",
state: false,
isStateMod: function() {
return true;
},
onToggle: function() {
this.state = !this.state;
if(this.state) {
//do something when this module is enabled
} else {
//do something when this module is disabled
}
},
onTick: function() {
//this will get called in modTick when the mod is enabled, also possible: onUseItem, onAttack, onHurt, onChat etcetera (add these functions separated by a comma, like what I did with onUseItem in this module)
},
onUseItem: function(x, y, z, itemId, blockId, side, blockDamage) {
//add your useItem code for this mod here
}
};
registerModule(exampleModule);
***************************************************************************************************************
Other parameters you can add to your modules are the following:
getSettingsLayout: function() {
var settingsLayout = new LinearLayout(ctx);
//add extra widgets (such as buttons and texts) in here, they will be displayed in a mod's ... dialog
return settingsLayout;
},
onModDialogDismiss: function() {
//this will be called when an user closes a mod's ... dialog
},
isBlockedByBypass: function() {
return false; //if the mod should be blocked by Bypass
}
If you want to store a variable in a module, simply add it like this: yourVariableName: yourVariableValue just like other parameters.
You can call this variable from within the module using this.yourVariableName.
It's still possible to use normal vars within the module's functions (onUseItem, onTick etcetera)
***************************************************************************************************************
var secondExampleModule = {
name: "Example non-toggleable module",
desc: "Example description.",
category: Category.COMBAT,
type: "Mod",
isStateMod: function() {
return false;
},
onToggle: function() {
//do something when an user taps on this mod's button
}
};
registerModule(secondExampleModule);
***************************************************************************************************************
Other functions and variables you can use in your addon are the following:
##################################
callFunction(functionName, propArray);
>> Example: callFunction("newLevel", []); <<
^^ In this example it will call newLevel in all scripts. This also works for other functions. ^^
!! Make sure to put the parameters in an array, otherwise it won't work!
----------------------------------
callVertexFunction(functionName, propArray);
>> Example: callVertexFunction("nuke", [getPlayerX(), getPlayerY(), getPlayerZ(), 3, "cube"]); <<
^^ In this example it will call Vertex Client PE's 'VertexClientPE.nuke' function without having to copy the whole function into your addon. This also works for other functions. ^^
** Supported since Vertex Client PE v2.4
!! Make sure to put the parameters in an array, otherwise it won't work!
----------------------------------
Launcher.isBlockLauncher();
>> Example: Launcher.isBlockLauncher(); <<
^^ This will return true if the user uses BlockLauncher. If not, it will return false.
----------------------------------
Launcher.isToolbox();
>> Example: Launcher.isToolbox(); <<
^^ This will return true if the user uses the Toolbox launcher. If not, it will return false.
----------------------------------
Launcher.isMcpeMaster();
>> Example: Launcher.isMcpeMaster(); <<
^^ This will return true if the user uses the MCPE Master launcher. If not, it will return false.
##################################
***************************************************************************************************************
*/
/**
* PART 2 OF THE FUNCTION LIBRARY (DON'T EDIT)
*/
function addonLoadHook() {
if(Launcher.isBlockLauncher() || Launcher.isToolbox()) {
net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod("registerAddon", [ADDON_NAME, ADDON_DESC, ADDON_VERSION, TARGET_VERSION, modules, songs, tiles, ADDON_AUTHOR]);
}
if(Launcher.isMcpeMaster()) {
com.mcbox.pesdk.mcpelauncher.ScriptManager.callScriptMethod("registerAddon", [ADDON_NAME, ADDON_DESC, ADDON_VERSION, TARGET_VERSION, modules, songs, tiles, ADDON_AUTHOR]);
}
}
function registerModule(obj) {
modules.push(obj);
}
function registerSong(song) {
try {
if(!(song instanceof Song)) {
throw new TypeError("The registered value is not of the type Song.");
return;
}
songs.push(song);
} catch(e) {
if(e instanceof TypeError) {
print("TypeError: " + e);
}
}
}
function registerTile(obj) {
tiles.push(obj);
}
function callFunction(functionName, propArray) {
if(Launcher.isBlockLauncher() || Launcher.isToolbox()) {
net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(functionName, propArray);
}
if(Launcher.isMcpeMaster()) {
com.mcbox.pesdk.mcpelauncher.ScriptManager.callScriptMethod(functionName, propArray);
}
}
function callVertexFunction(functionName, args) {
callFunction("callVertexFunctionCallback", [functionName, args]);
}