-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCInventory.js
More file actions
43 lines (37 loc) · 1.45 KB
/
MCInventory.js
File metadata and controls
43 lines (37 loc) · 1.45 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
import { MCComponent } from "./Component.js";
class MCInventory extends MCComponent {
constructor() {
super();
this.closeBtn = this.shadowRoot.querySelector(".mc-close-btn");
this.closeBtn.addEventListener("click", e => {
e.preventDefault();
this.dispatchEvent(new Event("closeBtnClick"));
return false;
});
this.itemList = this.shadowRoot.querySelector(".mc-inventory-items");
};
appendItem(block) {
let div = document.createElement("div");
div.classList = "mc-inventory-item-background";
div.appendChild(block.texture.inventory.cloneNode()).draggable = false;
div.data = block;
div.onclick = e => {
e.preventDefault();
this.dispatchEvent("inventoryItemClick", { global: true, data: block });
return false;
};
this.itemList.append(div);
};
clear() {
this.itemList.innerHTML = "";
};
};
MCInventory.setBorderAndWaitImg("inventory-items", ".mc-inventory-items");
MCInventory.setBorderAndWaitImg("inventory-tab-background-right", ".mc-inventory-tab-background-right");
MCInventory.setBackgroundAndWaitImg("close-btn", ".mc-close-btn");
MCInventory.setBackgroundAndWaitImg("close-btn-active", ".mc-close-btn:active");
MCInventory.setBackgroundAndWaitImg("inventory-item-background", ".mc-inventory-item-background");
MCInventory.asyncLoadAndDefine();
export {
MCInventory,
};