pw-js-world 0.0.1 → 0.0.3-dev.337233b

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pw-js-world",
3
- "version": "0.0.1",
3
+ "version": "0.0.3-dev.337233b",
4
4
  "description": "An optional package for PW-JS-Api, aims to serve world purposes.",
5
5
  "main": "lib/index.ts",
6
6
  "exports": {
package/bun.lockb DELETED
Binary file
package/test/index.ts DELETED
@@ -1,96 +0,0 @@
1
- import { LayerType } from "../lib/Constants";
2
- import { PWGameWorldHelper } from "../lib/index";
3
- import { BlockNames, PWApiClient } from "pw-js-api";
4
-
5
- const api = new PWApiClient("doomester@duck.com", "D!wr%Jy&z!uPSJ3m%5TG");
6
- const helper = new PWGameWorldHelper();
7
-
8
- await api.authenticate();
9
-
10
- const con = await api.joinWorld("rfdeeb8d9d94f76", {
11
- gameSettings: {
12
- handlePackets: ["PING", "INIT"]
13
- }
14
- });
15
-
16
- con
17
- // .addHook<{ playerInitPacket: { def: string } }>(() => {})
18
- .addHook(helper.receiveHook)
19
- .addCallback("playerInitPacket", (data, states) => {
20
- // console.log(states?.player?.isMe);
21
-
22
- states?.player?.username
23
-
24
- con.send("worldBlockPlacedPacket",
25
-
26
- helper.createBlockPacket(BlockNames.BASIC_GREEN, LayerType.Foreground, [{
27
- x: 18,
28
- y: 93
29
- }, {
30
- x: 19,
31
- y: 94
32
- }, {
33
- x: 20,
34
- y: 95
35
- }]));
36
-
37
- const signPack = helper.createBlockPacket(BlockNames.SIGN_BLUE, LayerType.Foreground, {
38
- x: 19,
39
- y: 98
40
- }, new Date().toString());
41
-
42
- console.log(signPack);
43
- con.send("worldBlockPlacedPacket", signPack);
44
-
45
- // console.log(data.globalSwitchState);
46
- })
47
- .addCallback("debug", egg => {
48
- if (!egg.includes("ping")) console.log(egg)
49
- })
50
-
51
- .addCallback("worldBlockPlacedPacket", (data, states) => {
52
- console.log("Prev Block Id: " + states?.oldBlocks[0].bId);
53
- console.log("Prev Block Args: " + states?.oldBlocks[0].args);
54
- console.log("New Block Id: " + states?.newBlocks[0].bId);
55
- console.log("New Block Args: " + states?.newBlocks[0].args);
56
- })
57
- .addCallback("playerChatPacket", (data, states) => {
58
- const msg = data.message;
59
- const args = msg.split(" ");
60
-
61
- switch (args[0]) {
62
- case "!at":
63
- if (args.length > 2) {
64
- const nums = [parseInt(args[1]), parseInt(args[2])];
65
-
66
- if (!nums.some(v => isNaN(v))) {
67
- const block = helper.getBlockAt(nums[0], nums[1], 1);
68
-
69
- return con.send("playerChatPacket", {
70
- message: "Block at (X: " + nums[0] + ", Y: " + nums[1] + ") - " + block.name + " (ID: " + block.bId + ", Args: " + block.hasArgs() + ")"
71
- })
72
- }
73
- }
74
- break;
75
- case "stat":
76
- {
77
- const player = states?.player;
78
-
79
- console.log({
80
- isMe: player?.isMe,
81
- id: player?.playerId,
82
- effects: player?.effects,
83
- face: player?.face,
84
- states: {
85
- coins: [player?.states.coinsGold, player?.states.coinsBlue],
86
- deaths: player?.states.deaths,
87
- collected: player?.states.collectedItems.length,
88
- modes: [player?.states.godmode, player?.states.modmode],
89
- teamId: player?.states.teamId
90
- },
91
- name: player?.username
92
- });
93
- }
94
- break;
95
- }
96
- })