@zardoy/flying-squid 0.0.129 → 0.0.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/containers/gameData.d.ts +45 -0
- package/dist/lib/containers/gameData.js +167 -0
- package/dist/lib/containers/loot.d.ts +67 -0
- package/dist/lib/containers/loot.js +388 -0
- package/dist/lib/containers/loot.test.d.ts +1 -0
- package/dist/lib/containers/loot.test.js +61 -0
- package/dist/lib/containers/store.d.ts +33 -0
- package/dist/lib/containers/store.js +190 -0
- package/dist/lib/modules/containers.d.ts +23 -0
- package/dist/lib/modules/containers.js +338 -0
- package/dist/lib/modules/index.js +2 -1
- package/dist/lib/modules/inventory.d.ts +5 -1
- package/dist/lib/modules/inventory.js +6 -5
- package/dist/lib/modules/playerLogin.d.ts +4 -0
- package/dist/lib/modules/playerLogin.js +11 -2
- package/dist/lib/modules/portal.d.ts +5 -1
- package/dist/lib/modules/portal.js +56 -1
- package/dist/lib/modules/respawn.js +8 -0
- package/dist/lib/modules/smelting.d.ts +6 -0
- package/dist/lib/modules/smelting.js +323 -0
- package/dist/lib/modules/world.d.ts +5 -0
- package/dist/lib/modules/world.js +29 -11
- package/dist/lib/playerDat.js +5 -1
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
- package/dist/lib/modules/chest.d.ts +0 -6
- package/dist/lib/modules/chest.js +0 -121
package/dist/lib/playerDat.js
CHANGED
|
@@ -70,6 +70,7 @@ async function read(uuid, getSpawnPoint, worldFolder, useInMemoryStorage) {
|
|
|
70
70
|
nbtItem.tag.name = '';
|
|
71
71
|
return nbtItem;
|
|
72
72
|
}),
|
|
73
|
+
enderItems: playerData.EnderItems?.value?.value ?? [],
|
|
73
74
|
new: false
|
|
74
75
|
};
|
|
75
76
|
}
|
|
@@ -148,7 +149,8 @@ async function save(player, worldFolder, snakeCase, theFlattening, useInMemorySt
|
|
|
148
149
|
onGround: player.onGround,
|
|
149
150
|
flying: player.flying ?? 0
|
|
150
151
|
},
|
|
151
|
-
inventory: playerInventoryToNBT(player.inventory, theFlattening)
|
|
152
|
+
inventory: playerInventoryToNBT(player.inventory, theFlattening),
|
|
153
|
+
enderItems: player.enderChestToNbt?.() ?? []
|
|
152
154
|
};
|
|
153
155
|
inMemoryStorage.set(player.uuid, playerData);
|
|
154
156
|
}
|
|
@@ -169,6 +171,8 @@ async function save(player, worldFolder, snakeCase, theFlattening, useInMemorySt
|
|
|
169
171
|
newUncompressedData.value.Rotation.value.value = [player.yaw, player.pitch];
|
|
170
172
|
newUncompressedData.value.OnGround.value = Number(player.onGround);
|
|
171
173
|
newUncompressedData.value.Inventory.value.value = playerInventoryToNBT(player.inventory, theFlattening);
|
|
174
|
+
const ender = player.enderChestToNbt?.() ?? [];
|
|
175
|
+
newUncompressedData.value.EnderItems = ender.length ? { type: 'list', value: { type: 'compound', value: ender } } : { type: 'list', value: { type: 'end', value: [] } };
|
|
172
176
|
newUncompressedData.value.abilities.value.flying.value = player.flying ?? 0;
|
|
173
177
|
const newDataCompressed = await (0, node_gzip_1.gzip)((0, prismarine_nbt_1.writeUncompressed)(newUncompressedData));
|
|
174
178
|
await fs_1.promises.writeFile(`${worldFolder}/playerdata/${player.uuid}.dat`, newDataCompressed);
|
package/dist/types.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import "./lib/modules/books.d.ts"
|
|
|
6
6
|
import "./lib/modules/bossBars.d.ts"
|
|
7
7
|
import "./lib/modules/channels.d.ts"
|
|
8
8
|
import "./lib/modules/chat.d.ts"
|
|
9
|
-
import "./lib/modules/chest.d.ts"
|
|
10
9
|
import "./lib/modules/commandBlocks.d.ts"
|
|
11
10
|
import "./lib/modules/commands.d.ts"
|
|
12
11
|
import "./lib/modules/communication.d.ts"
|
|
12
|
+
import "./lib/modules/containers.d.ts"
|
|
13
13
|
import "./lib/modules/crafting.d.ts"
|
|
14
14
|
import "./lib/modules/customBlockBreakTime.d.ts"
|
|
15
15
|
import "./lib/modules/customSync.d.ts"
|
|
@@ -51,6 +51,7 @@ import "./lib/modules/safeZones.d.ts"
|
|
|
51
51
|
import "./lib/modules/scoreboard.d.ts"
|
|
52
52
|
import "./lib/modules/settings.d.ts"
|
|
53
53
|
import "./lib/modules/signs.d.ts"
|
|
54
|
+
import "./lib/modules/smelting.d.ts"
|
|
54
55
|
import "./lib/modules/sound.d.ts"
|
|
55
56
|
import "./lib/modules/spawn.d.ts"
|
|
56
57
|
import "./lib/modules/stats.d.ts"
|
package/package.json
CHANGED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.server = void 0;
|
|
4
|
-
const vec3_1 = require("vec3");
|
|
5
|
-
const server = (serv, { version }) => {
|
|
6
|
-
serv.once('asap', () => {
|
|
7
|
-
// Importing necessary libraries
|
|
8
|
-
const registry = require('prismarine-registry')(version);
|
|
9
|
-
// Getting ALL supported blocks
|
|
10
|
-
// Chests
|
|
11
|
-
const blockChest = registry.blocksByName.chest;
|
|
12
|
-
const blockEnderChest = registry.blocksByName.ender_chest;
|
|
13
|
-
// TODO: Large chest (NOT IMPLEMENTED)
|
|
14
|
-
// Shulker boxes
|
|
15
|
-
let blockShulkerBox = [];
|
|
16
|
-
if (registry.supportFeature('theShulkerBoxes')) {
|
|
17
|
-
blockShulkerBox = [registry.blocksByName.shulker_box.id, registry.blocksByName.red_shulker_box.id,
|
|
18
|
-
registry.blocksByName.orange_shulker_box.id, registry.blocksByName.yellow_shulker_box.id, registry.blocksByName.lime_shulker_box.id,
|
|
19
|
-
registry.blocksByName.green_shulker_box.id, registry.blocksByName.light_blue_shulker_box.id, registry.blocksByName.cyan_shulker_box.id,
|
|
20
|
-
registry.blocksByName.blue_shulker_box.id, registry.blocksByName.purple_shulker_box.id, registry.blocksByName.magenta_shulker_box.id,
|
|
21
|
-
registry.blocksByName.brown_shulker_box.id, registry.blocksByName.gray_shulker_box.id, registry.blocksByName.light_gray_shulker_box.id,
|
|
22
|
-
registry.blocksByName.black_shulker_box.id, registry.blocksByName.white_shulker_box.id, registry.blocksByName.pink_shulker_box.id];
|
|
23
|
-
}
|
|
24
|
-
// Showing container GUI
|
|
25
|
-
const openContainerGUI = (block, player, guiType, title, sound) => {
|
|
26
|
-
// Default GUI shape and content
|
|
27
|
-
const guiContent = [
|
|
28
|
-
{ present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false },
|
|
29
|
-
{ present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false },
|
|
30
|
-
{ present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }, { present: false }
|
|
31
|
-
];
|
|
32
|
-
const invType = 2; // 3 rows, 9 slots
|
|
33
|
-
// Filling the GUI content and reshaping the GUI (if necessary)
|
|
34
|
-
switch (guiType) {
|
|
35
|
-
case 'chest':
|
|
36
|
-
// TODO: Gathering of content (NOT IMPLEMENTED)
|
|
37
|
-
break;
|
|
38
|
-
case 'double_chest':
|
|
39
|
-
// TODO: Gathering of content (NOT IMPLEMENTED)
|
|
40
|
-
break;
|
|
41
|
-
case 'ender_chest':
|
|
42
|
-
// TODO: Gathering of content (NOT IMPLEMENTED)
|
|
43
|
-
break;
|
|
44
|
-
case 'shulker_box':
|
|
45
|
-
// TODO: Gathering of content (NOT IMPLEMENTED)
|
|
46
|
-
break;
|
|
47
|
-
// TODO: Add more GUIs
|
|
48
|
-
}
|
|
49
|
-
if (sound) {
|
|
50
|
-
// Playing provided sound
|
|
51
|
-
serv.playSound(sound, player.world, block.position, {});
|
|
52
|
-
}
|
|
53
|
-
// Opening container GUI window
|
|
54
|
-
player._client.write('open_window', {
|
|
55
|
-
windowId: player.windowId,
|
|
56
|
-
inventoryType: invType,
|
|
57
|
-
windowTitle: serv._createChatComponent(title).toNetworkFormat()
|
|
58
|
-
});
|
|
59
|
-
// Sending container content
|
|
60
|
-
player._client.write('window_items', {
|
|
61
|
-
windowId: player.windowId,
|
|
62
|
-
stateId: 1,
|
|
63
|
-
items: guiContent,
|
|
64
|
-
carriedItem: { present: false }
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
// Interaction with a container block
|
|
68
|
-
const containerBlockInteractionHandler = async ({ block, player }) => {
|
|
69
|
-
player.chat('Chests are dangerous! Wait for the next update!');
|
|
70
|
-
return true; // NEED TO IMPLEMENT FIRST!!!
|
|
71
|
-
try {
|
|
72
|
-
// Getting current block and block above it
|
|
73
|
-
const id = await player.world.getBlockType(block.position);
|
|
74
|
-
const blockAbove = await player.world.getBlock(block.position.plus(new vec3_1.Vec3(0, 1, 0)));
|
|
75
|
-
// If there is any block directly above container then we can't open it
|
|
76
|
-
if (blockAbove?.boundingBox === 'block') {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
// Dynamic window ID feature
|
|
80
|
-
if (player.windowId === undefined) {
|
|
81
|
-
player.windowId = 1;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
player.windowId = player.windowId + 1;
|
|
85
|
-
}
|
|
86
|
-
player.windowPos = block.position;
|
|
87
|
-
if (id === blockChest.id) {
|
|
88
|
-
player.windowType = 'chest';
|
|
89
|
-
openContainerGUI(block, player, 'chest', { translate: 'container.chest' }, 'block.chest.open');
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
if (id === blockEnderChest.id) {
|
|
93
|
-
player.windowType = 'ender_chest';
|
|
94
|
-
openContainerGUI(block, player, 'ender_chest', { translate: 'container.enderchest' }, 'block.chest.open');
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
// TODO: Large chest (NOT IMPLEMENTED)
|
|
98
|
-
if (blockShulkerBox.includes(id)) {
|
|
99
|
-
player.windowType = 'shulker_box';
|
|
100
|
-
openContainerGUI(block, player, 'shulker_box', { translate: 'container.shulkerBox' }, 'block.chest.open');
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
setTimeout(() => { throw err; }, 0);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
// Registering block interaction handlers
|
|
109
|
-
// Chests
|
|
110
|
-
serv.onBlockInteraction(registry.blocksByName.chest.name, containerBlockInteractionHandler);
|
|
111
|
-
serv.onBlockInteraction(registry.blocksByName.ender_chest.name, containerBlockInteractionHandler);
|
|
112
|
-
// TODO: Large chest (NOT IMPLEMENTED)
|
|
113
|
-
// Shulker boxes
|
|
114
|
-
if (registry.supportFeature('theShulkerBoxes')) {
|
|
115
|
-
for (const currentShulkerBoxID of blockShulkerBox) {
|
|
116
|
-
serv.onBlockInteraction(registry.blocks[currentShulkerBoxID].name, containerBlockInteractionHandler);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
exports.server = server;
|