hytopia 0.1.34 → 0.1.36

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.
Files changed (70) hide show
  1. package/README.md +3 -1
  2. package/docs/server.audio.md +1 -1
  3. package/docs/server.blocktype.md +1 -1
  4. package/docs/server.blocktyperegistry.md +2 -2
  5. package/docs/server.blocktyperegistry.registerblocktype.md +2 -18
  6. package/docs/server.chunk.getblock.md +55 -0
  7. package/docs/server.chunk.hasblock.md +55 -0
  8. package/docs/server.chunk.md +28 -0
  9. package/docs/server.chunklattice.getblock.md +55 -0
  10. package/docs/server.chunklattice.hasblock.md +55 -0
  11. package/docs/server.chunklattice.md +29 -1
  12. package/docs/server.chunklattice.setblock.md +2 -2
  13. package/docs/server.entity.md +35 -0
  14. package/docs/server.entity.settintcolor.md +53 -0
  15. package/docs/server.entity.tintcolor.md +13 -0
  16. package/docs/server.entityeventpayload.md +9 -0
  17. package/docs/server.entityeventpayload.settintcolor.entity.md +11 -0
  18. package/docs/server.entityeventpayload.settintcolor.md +70 -0
  19. package/docs/server.entityeventpayload.settintcolor.tintcolor.md +11 -0
  20. package/docs/server.entityeventtype.md +15 -1
  21. package/docs/server.entityoptions.md +19 -0
  22. package/docs/server.entityoptions.tintcolor.md +13 -0
  23. package/docs/server.gameserver.md +1 -1
  24. package/docs/server.hytopia.audio.md +1 -1
  25. package/docs/server.hytopia.blocktype.md +1 -1
  26. package/docs/server.hytopia.blocktyperegistry.md +2 -2
  27. package/docs/server.hytopia.blocktyperegistry.registerblocktype.md +2 -18
  28. package/docs/server.hytopia.chunk.getblock.md +55 -0
  29. package/docs/server.hytopia.chunk.hasblock.md +55 -0
  30. package/docs/server.hytopia.chunk.md +28 -0
  31. package/docs/server.hytopia.chunklattice.getblock.md +55 -0
  32. package/docs/server.hytopia.chunklattice.hasblock.md +55 -0
  33. package/docs/server.hytopia.chunklattice.md +29 -1
  34. package/docs/server.hytopia.chunklattice.setblock.md +2 -2
  35. package/docs/server.hytopia.entity.md +35 -0
  36. package/docs/server.hytopia.entity.settintcolor.md +53 -0
  37. package/docs/server.hytopia.entity.tintcolor.md +13 -0
  38. package/docs/server.hytopia.entityeventpayload.md +9 -0
  39. package/docs/server.hytopia.entityeventpayload.settintcolor.entity.md +11 -0
  40. package/docs/server.hytopia.entityeventpayload.settintcolor.md +70 -0
  41. package/docs/server.hytopia.entityeventpayload.settintcolor.tintcolor.md +11 -0
  42. package/docs/server.hytopia.entityeventtype.md +15 -1
  43. package/docs/server.hytopia.entityoptions.md +19 -0
  44. package/docs/server.hytopia.entityoptions.tintcolor.md +13 -0
  45. package/docs/server.hytopia.gameserver.md +1 -1
  46. package/docs/server.hytopia.md +11 -11
  47. package/docs/server.hytopia.rgbcolor.b.md +11 -0
  48. package/docs/server.hytopia.rgbcolor.g.md +11 -0
  49. package/docs/server.hytopia.rgbcolor.md +89 -0
  50. package/docs/server.hytopia.rgbcolor.r.md +11 -0
  51. package/docs/server.hytopia.simulation.md +14 -0
  52. package/docs/server.hytopia.simulation.setgravity.md +53 -0
  53. package/docs/server.hytopia.worldmap.blocktypes.md +1 -5
  54. package/docs/server.hytopia.worldmap.md +1 -1
  55. package/docs/server.md +11 -11
  56. package/docs/server.rgbcolor.b.md +11 -0
  57. package/docs/server.rgbcolor.g.md +11 -0
  58. package/docs/server.rgbcolor.md +89 -0
  59. package/docs/server.rgbcolor.r.md +11 -0
  60. package/docs/server.simulation.md +14 -0
  61. package/docs/server.simulation.setgravity.md +53 -0
  62. package/docs/server.worldmap.blocktypes.md +1 -5
  63. package/docs/server.worldmap.md +1 -1
  64. package/package.json +1 -1
  65. package/readme/assets/banner-2.jpeg +0 -0
  66. package/server.api.json +1277 -219
  67. package/server.d.ts +61 -42
  68. package/server.js +79 -79
  69. package/docs/server.hytopia.webserver.md +0 -20
  70. package/docs/server.webserver.md +0 -20
package/server.d.ts CHANGED
@@ -23,7 +23,7 @@ import { WebSocket as WebSocket_2 } from 'ws';
23
23
  * @example
24
24
  * ```typescript
25
25
  * (new Audio({
26
- * uri: 'assets/music/song.mp3',
26
+ * uri: 'music/song.mp3', // relative to the server's assets directory in the project root, resolves to assets/music/song.mp3
27
27
  * loop: true,
28
28
  * volume: 0.5,
29
29
  * })).play(world);
@@ -365,7 +365,7 @@ export declare class Block {
365
365
  * const stoneBlockTypeId = 10;
366
366
  * world.blockTypeRegistry.registerBlockType(stoneBlockTypeId, new BlockType({
367
367
  * id: stoneBlockTypeId,
368
- * textureUri: 'assets/textures/stone.png',
368
+ * textureUri: 'textures/stone.png',
369
369
  * name: 'Stone',
370
370
  * }));
371
371
  *
@@ -435,7 +435,7 @@ export declare interface BlockTypeOptions {
435
435
  * ```typescript
436
436
  * world.blockTypeRegistry.registerGenericBlockType({
437
437
  * id: 15,
438
- * textureUri: 'assets/textures/dirt.png',
438
+ * textureUri: 'textures/dirt.png',
439
439
  * name: 'Dirt',
440
440
  * });
441
441
  * ```
@@ -467,10 +467,9 @@ export declare class BlockTypeRegistry implements protocol.Serializable {
467
467
  registerGenericBlockType(blockTypeOptions: BlockTypeOptions): BlockType;
468
468
  /**
469
469
  * Register a block type.
470
- * @param id - The id of the block type to register.
471
- * @param blockTypeReference - The block type to register.
470
+ * @param blockType - The block type to register.
472
471
  */
473
- registerBlockType(id: number, blockTypeReference: BlockType): void;
472
+ registerBlockType(blockType: BlockType): void;
474
473
 
475
474
  }
476
475
 
@@ -664,6 +663,18 @@ export declare class Chunk implements protocol.Serializable {
664
663
  * Despawn the chunk from the world.
665
664
  */
666
665
  despawn(): void;
666
+ /**
667
+ * Get the block type id at a specific local coordinate.
668
+ * @param localCoordinate - The local coordinate of the block to get.
669
+ * @returns The block type id.
670
+ */
671
+ getBlock(localCoordinate: Vector3): number;
672
+ /**
673
+ * Check if a block exists at a specific local coordinate.
674
+ * @param localCoordinate - The local coordinate of the block to check.
675
+ * @returns Whether a block exists.
676
+ */
677
+ hasBlock(localCoordinate: Vector3): boolean;
667
678
  /**
668
679
  * Set the block at a specific local coordinate by block type id.
669
680
  * @param localCoordinate - The local coordinate of the block to set.
@@ -721,6 +732,12 @@ export declare class ChunkLattice {
721
732
  constructor(world: World);
722
733
 
723
734
 
735
+ /**
736
+ * Get the block type id at a specific global coordinate.
737
+ * @param globalCoordinate - The global coordinate of the block to get.
738
+ * @returns The block type id, 0 if no block is set.
739
+ */
740
+ getBlock(globalCoordinate: Vector3): number;
724
741
  /**
725
742
  * Get a chunk by its origin coordinate.
726
743
  * @param originCoordinate - The origin coordinate of the chunk to get.
@@ -732,6 +749,12 @@ export declare class ChunkLattice {
732
749
  * @returns An array of all chunks in the lattice.
733
750
  */
734
751
  getAllChunks(): Chunk[];
752
+ /**
753
+ * Check if a block exists at a specific global coordinate.
754
+ * @param globalCoordinate - The global coordinate of the block to check.
755
+ * @returns Whether a block exists.
756
+ */
757
+ hasBlock(globalCoordinate: Vector3): boolean;
735
758
  /**
736
759
  * Check if a chunk exists by its origin coordinate.
737
760
  * @param originCoordinate - The origin coordinate of the chunk to check.
@@ -740,9 +763,9 @@ export declare class ChunkLattice {
740
763
  hasChunk(originCoordinate: Vector3): boolean;
741
764
  /**
742
765
  * Set the block at a global coordinate by block type id, automatically
743
- * creating a chunk if it doesn't exist.
766
+ * creating a chunk if it doesn't exist. Use block type id 0 for air.
744
767
  * @param globalCoordinate - The global coordinate of the block to set.
745
- * @param blockTypeId - The block type id to set.
768
+ * @param blockTypeId - The block type id to set. Use 0 to remove the block and replace with air.
746
769
  */
747
770
  setBlock(globalCoordinate: Vector3, blockTypeId: number): void;
748
771
 
@@ -1269,6 +1292,7 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1269
1292
 
1270
1293
 
1271
1294
 
1295
+
1272
1296
  /**
1273
1297
  * @param options - The options for the entity.
1274
1298
  */
@@ -1291,6 +1315,8 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1291
1315
  get name(): string;
1292
1316
  /** An arbitrary identifier tag of the entity. Useful for your own logic. */
1293
1317
  get tag(): string | undefined;
1318
+ /** The tint color of the entity. */
1319
+ get tintColor(): RgbColor | undefined;
1294
1320
  /** Whether the entity is spawned. */
1295
1321
  get isSpawned(): boolean;
1296
1322
  /** The world the entity is in. */
@@ -1310,6 +1336,11 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1310
1336
  * @param characterController - The character controller to set.
1311
1337
  */
1312
1338
  setCharacterController(characterController: BaseCharacterController): void;
1339
+ /**
1340
+ * Sets the tint color of the entity.
1341
+ * @param tintColor - The tint color of the entity.
1342
+ */
1343
+ setTintColor(tintColor: RgbColor | undefined): void;
1313
1344
  /**
1314
1345
  * Starts looped animations for the entity, blending with
1315
1346
  * other animations currently playing.
@@ -1341,6 +1372,10 @@ export declare namespace EntityEventPayload {
1341
1372
  export interface Despawn {
1342
1373
  entity: Entity;
1343
1374
  }
1375
+ export interface SetTintColor {
1376
+ entity: Entity;
1377
+ tintColor: RgbColor | undefined;
1378
+ }
1344
1379
  export interface Spawn {
1345
1380
  entity: Entity;
1346
1381
  }
@@ -1369,8 +1404,9 @@ export declare namespace EntityEventPayload {
1369
1404
  /** Event types an Entity instance can emit. @public */
1370
1405
  export declare enum EntityEventType {
1371
1406
  DESPAWN = "ENTITY.DESPAWN",
1407
+ SET_TINT_COLOR = "ENTITY.SET_TINT_COLOR",
1372
1408
  SPAWN = "ENTITY.SPAWN",
1373
- START_MODEL_LOOPED_ANIMATIONS = "ENTITY.UPDATE_MODEL_LOOPED_ANIMATIONS",
1409
+ START_MODEL_LOOPED_ANIMATIONS = "ENTITY.START_MODEL_LOOPED_ANIMATIONS",
1374
1410
  START_MODEL_ONESHOT_ANIMATIONS = "ENTITY.START_MODEL_ONESHOT_ANIMATIONS",
1375
1411
  STOP_MODEL_ANIMATIONS = "ENTITY.STOP_MODEL_ANIMATIONS",
1376
1412
  UPDATE_ROTATION = "ENTITY.UPDATE_ROTATION",
@@ -1461,6 +1497,8 @@ export declare interface EntityOptions {
1461
1497
  rigidBodyOptions?: RigidBodyOptions;
1462
1498
  /** An arbitrary identifier tag of the entity. Useful for your own logic. */
1463
1499
  tag?: string;
1500
+ /** The tint color of the entity as a hex code. */
1501
+ tintColor?: RgbColor;
1464
1502
  }
1465
1503
 
1466
1504
  /** An EventRouter event. @public */
@@ -1658,6 +1696,7 @@ declare namespace HYTOPIA {
1658
1696
  GameServerEventType,
1659
1697
  startServer,
1660
1698
  GameServerEventPayload,
1699
+ RgbColor,
1661
1700
  Rotation,
1662
1701
  SpdMatrix3,
1663
1702
  Vector3,
@@ -1687,7 +1726,6 @@ declare namespace HYTOPIA {
1687
1726
  MoveCompleteCallback,
1688
1727
  MoveOptions,
1689
1728
  Simulation,
1690
- WebServer,
1691
1729
  PORT,
1692
1730
  World,
1693
1731
  WorldMap,
@@ -2152,6 +2190,13 @@ declare type RayCastOptions = {
2152
2190
  filterPredicate?: (collider: RAPIER.Collider) => boolean;
2153
2191
  };
2154
2192
 
2193
+ /** A RGB color. @public */
2194
+ export declare interface RgbColor {
2195
+ r: number;
2196
+ g: number;
2197
+ b: number;
2198
+ }
2199
+
2155
2200
  /**
2156
2201
  * Represents a rigid body in a world's physics simulation.
2157
2202
  *
@@ -2724,6 +2769,11 @@ export declare class Simulation {
2724
2769
  enableDebugRendering(enabled: boolean): void;
2725
2770
 
2726
2771
 
2772
+ /**
2773
+ * Sets the gravity vector for the simulation.
2774
+ * @param gravity - The gravity vector.
2775
+ */
2776
+ setGravity(gravity: RAPIER.Vector3): void;
2727
2777
 
2728
2778
 
2729
2779
 
@@ -2764,30 +2814,6 @@ export declare interface Vector3Boolean {
2764
2814
  x: boolean;
2765
2815
  y: boolean;
2766
2816
  z: boolean;
2767
- }
2768
-
2769
- /**
2770
- * Manages the internal HTTP server for the game server.
2771
- *
2772
- * @remarks
2773
- * This class is used as a singleton and should be
2774
- * accessed via the GameServer.webServer property.
2775
- *
2776
- * @public
2777
- */
2778
- export declare class WebServer {
2779
-
2780
-
2781
-
2782
-
2783
-
2784
-
2785
-
2786
-
2787
-
2788
-
2789
-
2790
-
2791
2817
  }
2792
2818
 
2793
2819
  /**
@@ -2956,14 +2982,7 @@ export declare enum WorldLoopEventType {
2956
2982
  /** A map representation for a world. @public */
2957
2983
  export declare interface WorldMap {
2958
2984
  /** The block types in the map. */
2959
- blockTypes: {
2960
- /** The ID of the block type. */
2961
- id: number;
2962
- /** The name of the block type. */
2963
- name: string;
2964
- /** The URI of the texture for the block type. */
2965
- textureUri: string;
2966
- }[];
2985
+ blockTypes: BlockTypeOptions[];
2967
2986
  /** The blocks in the map */
2968
2987
  blocks: {
2969
2988
  /** The global coordinate to block type id mapping. */