-
Notifications
You must be signed in to change notification settings - Fork 35
/
500ise_enchantingbench.js
53 lines (47 loc) · 1.91 KB
/
500ise_enchantingbench.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
//example enchantment bench script by 500 Internal Server Error
//uses block ID 187
//use give commands to give yourself block 187; when tapped, it opens the crafting menu
//this script is licensed under CC0: you may do whatever you want with it.
var ENCHANTMENT_TABLE_ID = 240;
var currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ;
var needToSwitchBack = false;
// define a block with ID 187, name "Enchantment table", and the following textures
// in the order (bottom, top, south, north, west, east).
// in this case, the side textures are the same, and the top/bottom textures are different.
Block.defineBlock(ENCHANTMENT_TABLE_ID, "Enchantment table",
[["enchanting_table_bottom", 0], ["enchanting_table_top", 0],
["enchanting_table_side", 0], ["enchanting_table_side", 0],
["enchanting_table_side", 0], ["enchanting_table_side", 0]]);
// sets the block's boundaries.
// the order of parameters: xmin, ymin, zmin, xmax, ymax, zmax
// in this case, the block starts at y = 0, and stops at y = 0.75 - this is a block 3/4 m high.
Block.setShape(ENCHANTMENT_TABLE_ID, 0, 0, 0, 1, 3/4, 1);
Block.setDestroyTime(ENCHANTMENT_TABLE_ID, 1);
Item.addShapedRecipe(ENCHANTMENT_TABLE_ID, 1, 0, [
" b ", //draw the shape of the recipe
"dod",
"ooo"], [
"b", 340, 0, //specify what each character represents. b -> book, etc
"d", 264, 0,
"o", 49, 0]);
function useItem(x, y, z, itemId, blockId, side) {
if (blockId == ENCHANTMENT_TABLE_ID) {
currentWorkbenchX = x;
currentWorkbenchY = y;
currentWorkbenchZ = z;
setTile(x, y, z, 58); //set to workbench so Minecraft PE would open the crafting menu
needToSwitchBack = true;
}
}
function procCmd(cmd) {
if (cmd == "enchanttable") {
addItemInventory(ENCHANTMENT_TABLE_ID, 1);
}
}
function modTick() {
if (needToSwitchBack) {
needToSwitchBack = false;
setTile(currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ, ENCHANTMENT_TABLE_ID);
//switch it back to the original
}
}