@zardoy/flying-squid 0.0.90 → 0.0.91
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Vec3 } from 'vec3';
|
|
1
2
|
export declare const player: (player: Player, serv: Server) => void;
|
|
2
3
|
export declare const server: (serv: Server, { version }: Options) => void;
|
|
3
4
|
declare global {
|
|
@@ -7,14 +8,14 @@ declare global {
|
|
|
7
8
|
* this will not change the block for the user himself. It is mainly useful when a user places a block
|
|
8
9
|
* and only needs to send it to other players on the server
|
|
9
10
|
*/
|
|
10
|
-
'changeBlock': (position:
|
|
11
|
+
'changeBlock': (position: Vec3, blockType: number, blockData: any) => Promise<void>;
|
|
11
12
|
/** change the block at position `position` to `blockType` and `blockData`
|
|
12
13
|
*
|
|
13
14
|
* this will not make any changes on the server's world and only sends it to the user as a "fake" or "local" block
|
|
14
15
|
*/
|
|
15
|
-
'sendBlock': (position:
|
|
16
|
+
'sendBlock': (position: Vec3, blockStateId: number) => any;
|
|
16
17
|
/** Saves block in world and sends block update to all players of the same world. */
|
|
17
|
-
'setBlock': (position:
|
|
18
|
+
'setBlock': (position: Vec3, stateId: number) => any;
|
|
18
19
|
/** Set the block action at position `position` to `actionId` and `actionParam`.
|
|
19
20
|
*
|
|
20
21
|
* ``blockType`` is only required when the block at the location is a fake block.
|
|
@@ -22,11 +23,11 @@ declare global {
|
|
|
22
23
|
*
|
|
23
24
|
* This will not make any changes to the server's world and only sends it to the user as a local action.
|
|
24
25
|
*/
|
|
25
|
-
'sendBlockAction': (position:
|
|
26
|
+
'sendBlockAction': (position: Vec3, actionId: number, actionParam: number, blockType: number) => Promise<void>;
|
|
26
27
|
/** Sets a block action and sends the block action to all players in the same world.
|
|
27
28
|
*
|
|
28
29
|
* This will not make any changes to the server's world
|
|
29
30
|
*/
|
|
30
|
-
'setBlockAction': (position:
|
|
31
|
+
'setBlockAction': (position: Vec3, actionId: number, actionParam: number) => any;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -97,9 +97,9 @@ const server = function (serv, { version }) {
|
|
|
97
97
|
},
|
|
98
98
|
action(params, ctx) {
|
|
99
99
|
if (ctx.player)
|
|
100
|
-
ctx.player.setBlockAction(new vec3_1.Vec3(+params[1], +params[2], +params[3]).floored(), +params[4], params[5]);
|
|
100
|
+
ctx.player.setBlockAction(new vec3_1.Vec3(+params[1], +params[2], +params[3]).floored(), +params[4], Number(params[5]));
|
|
101
101
|
else
|
|
102
|
-
serv.setBlockAction(serv.overworld, new vec3_1.Vec3(+params[1], +params[2], +params[3]).floored(), +params[4], params[5]);
|
|
102
|
+
serv.setBlockAction(serv.overworld, new vec3_1.Vec3(+params[1], +params[2], +params[3]).floored(), +params[4], Number(params[5]));
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
serv.commands.add({
|
|
@@ -113,11 +113,16 @@ const server = function (serv, { version }) {
|
|
|
113
113
|
action([_sX, _sY, _sZ, _tX, _tY, _tZ, blockArg], ctx) {
|
|
114
114
|
const [sX, sY, sZ, tX, tY, tZ] = [_sX, _sY, _sZ, _tX, _tY, _tZ].map(x => +x);
|
|
115
115
|
const block = []; // todo resolve block
|
|
116
|
+
let changes = 0;
|
|
116
117
|
for (let x = Math.min(sX, tX); x <= Math.max(sX, tX); x++) {
|
|
117
118
|
for (let y = Math.min(sY, tY); y <= Math.max(sY, tY); y++) {
|
|
118
119
|
for (let z = Math.min(sZ, tZ); z <= Math.max(sZ, tZ); z++) {
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
ctx.player.setBlock(new vec3_1.Vec3(x, y, z), 0);
|
|
121
|
+
changes++;
|
|
122
|
+
if (changes > 1000) {
|
|
123
|
+
ctx.player.chat(`[Fill] Made ${changes} changes`);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
}
|
|
@@ -7,7 +7,7 @@ const player = function (player, serv, { version }) {
|
|
|
7
7
|
function cancelDig({ position, block }) {
|
|
8
8
|
player.sendBlock(position, block.type);
|
|
9
9
|
}
|
|
10
|
-
player._client.on('block_dig',
|
|
10
|
+
player._client.on('block_dig', ({ location, status, face }) => {
|
|
11
11
|
if (status === 3 || status === 4) {
|
|
12
12
|
const heldItem = player.inventory.slots[36 + player.heldItemSlot];
|
|
13
13
|
if (!heldItem || heldItem.type === -1)
|
|
@@ -47,14 +47,20 @@ const player = function (player, serv, { version }) {
|
|
|
47
47
|
directionVector = new vec3_1.Vec3(0, 0, 0);
|
|
48
48
|
}
|
|
49
49
|
const facedPos = pos.plus(directionVector);
|
|
50
|
-
const
|
|
50
|
+
const columnFaced = player.world.getLoadedColumnAt(facedPos);
|
|
51
|
+
const columnBlock = player.world.getLoadedColumnAt(pos);
|
|
52
|
+
if (!columnFaced || !columnBlock) {
|
|
53
|
+
console.warn(`[Digging] Column not loaded for player ${player.username} at ${pos}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const facedBlock = columnFaced.getBlock(new vec3_1.Vec3(facedPos.x & 15, 0, facedPos.z & 15));
|
|
51
57
|
let block;
|
|
52
58
|
if (facedBlock.name === 'fire') {
|
|
53
59
|
block = facedBlock;
|
|
54
60
|
pos = facedPos;
|
|
55
61
|
}
|
|
56
62
|
else {
|
|
57
|
-
block =
|
|
63
|
+
block = columnBlock.getBlock(new vec3_1.Vec3(pos.x & 15, 0, pos.z & 15));
|
|
58
64
|
}
|
|
59
65
|
currentlyDugBlock = block;
|
|
60
66
|
if (currentlyDugBlock.type === 0)
|
|
@@ -71,7 +77,7 @@ const player = function (player, serv, { version }) {
|
|
|
71
77
|
cancelDigging(pos);
|
|
72
78
|
}
|
|
73
79
|
else if (status === 2) {
|
|
74
|
-
completeDigging(pos);
|
|
80
|
+
completeDigging(pos, directionVector);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
});
|
|
@@ -143,7 +149,7 @@ const player = function (player, serv, { version }) {
|
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
const blockDropVelocity = new vec3_1.Vec3(Math.random() * 4 - 2, Math.random() * 2 + 2, Math.random() * 4 - 2);
|
|
146
|
-
async function completeDigging(location) {
|
|
152
|
+
async function completeDigging(location, directionVector) {
|
|
147
153
|
clearInterval(animationInterval);
|
|
148
154
|
const diggingTime = Date.now() - startDiggingTime;
|
|
149
155
|
let stop = false;
|
|
@@ -195,7 +201,8 @@ const player = function (player, serv, { version }) {
|
|
|
195
201
|
position: location,
|
|
196
202
|
block: currentlyDugBlock,
|
|
197
203
|
dropBlock: true,
|
|
198
|
-
drops
|
|
204
|
+
drops,
|
|
205
|
+
directionVector
|
|
199
206
|
}, async (data) => {
|
|
200
207
|
player.changeBlock(data.position, 0, 0);
|
|
201
208
|
const aboveBlock = await player.world.getBlock(data.position.offset(0, 1, 0));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Vec3 } from 'vec3';
|
|
1
2
|
export declare const server: (serv: Server) => void;
|
|
2
3
|
declare global {
|
|
3
4
|
interface Server {
|
|
@@ -11,7 +12,7 @@ declare global {
|
|
|
11
12
|
* - size: vec3 of the size. (0,0,0) will be at an exact position, (10,10,10) will be very spread out (particles less dense)
|
|
12
13
|
* - count: Number of particles. 100,000,000+ will crash the client. Try not to go over 100,000 (sincerely, minecraft clients)
|
|
13
14
|
*/
|
|
14
|
-
'emitParticle': (particle: any, world: any, position:
|
|
15
|
+
'emitParticle': (particle: any, world: any, position: Vec3, { whitelist, blacklist, radius, longDistance, size, count }?: {
|
|
15
16
|
whitelist?: any;
|
|
16
17
|
blacklist?: any[] | undefined;
|
|
17
18
|
radius?: number | undefined;
|
package/dist/modules.d.ts
CHANGED