hytopia 0.14.25 → 0.14.27

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 (35) hide show
  1. package/bin/scripts.js +3 -3
  2. package/client-docs/client.hytopiaui.freezepointerlock.md +54 -0
  3. package/client-docs/client.hytopiaui.lockpointer.md +1 -1
  4. package/client-docs/client.hytopiaui.md +15 -1
  5. package/docs/server.blocktype.interact.md +73 -0
  6. package/docs/server.blocktype.md +34 -0
  7. package/docs/server.blocktypeevent.md +14 -0
  8. package/docs/server.blocktypeeventpayloads._block_type.interact_.md +17 -0
  9. package/docs/server.blocktypeeventpayloads.md +19 -0
  10. package/docs/server.entity.interact.md +73 -0
  11. package/docs/server.entity.isenvironmental.md +1 -1
  12. package/docs/server.entity.md +15 -1
  13. package/docs/server.entityevent.md +14 -0
  14. package/docs/server.entityeventpayloads._entity.interact_.md +17 -0
  15. package/docs/server.entityeventpayloads.md +19 -0
  16. package/docs/server.player.interactenabled.md +13 -0
  17. package/docs/server.player.maxinteractdistance.md +13 -0
  18. package/docs/server.player.md +70 -0
  19. package/docs/server.player.setinteractenabled.md +53 -0
  20. package/docs/server.player.setmaxinteractdistance.md +53 -0
  21. package/docs/server.playerevent.md +14 -0
  22. package/docs/server.playereventpayloads._player.interact_.md +18 -0
  23. package/docs/server.playereventpayloads.md +19 -0
  24. package/docs/server.playerui.freezepointerlock.md +53 -0
  25. package/docs/server.playerui.lockpointer.md +5 -1
  26. package/docs/server.playerui.md +15 -1
  27. package/docs/server.playeruievent.md +14 -0
  28. package/docs/server.playeruieventpayloads._player_ui.freeze_pointer_lock_.md +16 -0
  29. package/docs/server.playeruieventpayloads.md +19 -0
  30. package/docs/server.raycasthit.md +2 -0
  31. package/docs/server.supported_inputs.md +1 -1
  32. package/package.json +1 -1
  33. package/server.api.json +686 -5
  34. package/server.d.ts +85 -5
  35. package/server.mjs +81 -81
package/server.d.ts CHANGED
@@ -730,13 +730,25 @@ export declare class BlockType extends EventRouter implements protocol.Serializa
730
730
  /** The URI of the texture for the block type. */
731
731
  get textureUri(): string;
732
732
 
733
+ /**
734
+ * Triggers an interaction on the block type from a player.
735
+ *
736
+ * @remarks
737
+ * This is automatically called when a player clicks or taps a block of this block type, but can also be called directly
738
+ * for programmatic interactions. Emits {@link BlockTypeEvent.INTERACT}.
739
+ *
740
+ * @param player - The player interacting with the block type.
741
+ * @param raycastHit - The raycast hit result, if the interaction was triggered by a client-side click/tap.
742
+ */
743
+ interact(player: Player, raycastHit?: RaycastHit): void;
733
744
 
734
745
  }
735
746
 
736
747
  /** Event types a BlockType instance can emit. See {@link BlockTypeEventPayloads} for the payloads. @public */
737
748
  export declare enum BlockTypeEvent {
738
749
  ENTITY_COLLISION = "BLOCK_TYPE.ENTITY_COLLISION",
739
- ENTITY_CONTACT_FORCE = "BLOCK_TYPE.ENTITY_CONTACT_FORCE"
750
+ ENTITY_CONTACT_FORCE = "BLOCK_TYPE.ENTITY_CONTACT_FORCE",
751
+ INTERACT = "BLOCK_TYPE.INTERACT"
740
752
  }
741
753
 
742
754
  /** Event payloads for BlockType emitted events. @public */
@@ -755,6 +767,12 @@ export declare interface BlockTypeEventPayloads {
755
767
  entity: Entity;
756
768
  contactForceData: ContactForceData;
757
769
  };
770
+ /** Emitted when a player interacts with a block type. */
771
+ [BlockTypeEvent.INTERACT]: {
772
+ blockType: BlockType;
773
+ player: Player;
774
+ raycastHit?: RaycastHit;
775
+ };
758
776
  }
759
777
 
760
778
  /** Options for creating a block type instance. @public */
@@ -1941,7 +1959,7 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1941
1959
  get tintColor(): RgbColor | undefined;
1942
1960
  /** Whether the entity is a block entity. */
1943
1961
  get isBlockEntity(): boolean;
1944
- /** Whether the entity is environmental, if true it will not invoke its tick function or change position. */
1962
+ /** Whether the entity is environmental, if true it will not invoke its tick function or change position. It also cannot be animated or removed after spawning. */
1945
1963
  get isEnvironmental(): boolean;
1946
1964
  /** Whether the entity is a model entity. */
1947
1965
  get isModelEntity(): boolean;
@@ -1962,6 +1980,17 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1962
1980
  * Despawns the entity and all children from the world.
1963
1981
  */
1964
1982
  despawn(): void;
1983
+ /**
1984
+ * Triggers an interaction on the entity from a player.
1985
+ *
1986
+ * @remarks
1987
+ * This is automatically called when a player clicks or taps the entity, but can also be called directly
1988
+ * for programmatic interactions. Emits {@link EntityEvent.INTERACT}.
1989
+ *
1990
+ * @param player - The player interacting with the entity.
1991
+ * @param raycastHit - The raycast hit result, if the interaction was triggered by a client-side click/tap.
1992
+ */
1993
+ interact(player: Player, raycastHit?: RaycastHit): void;
1965
1994
  /**
1966
1995
  * Sets the controller for the entity.
1967
1996
  * @param controller - The controller to set.
@@ -2100,6 +2129,7 @@ export declare enum EntityEvent {
2100
2129
  DESPAWN = "ENTITY.DESPAWN",
2101
2130
  ENTITY_COLLISION = "ENTITY.ENTITY_COLLISION",
2102
2131
  ENTITY_CONTACT_FORCE = "ENTITY.ENTITY_CONTACT_FORCE",
2132
+ INTERACT = "ENTITY.INTERACT",
2103
2133
  SET_MODEL_ANIMATIONS_PLAYBACK_RATE = "ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",
2104
2134
  SET_MODEL_HIDDEN_NODES = "ENTITY.SET_MODEL_HIDDEN_NODES",
2105
2135
  SET_MODEL_SCALE = "ENTITY.SET_MODEL_SCALE",
@@ -2151,6 +2181,12 @@ export declare interface EntityEventPayloads {
2151
2181
  otherEntity: Entity;
2152
2182
  contactForceData: ContactForceData;
2153
2183
  };
2184
+ /** Emitted when a player interacts with the entity by clicking or tapping it. */
2185
+ [EntityEvent.INTERACT]: {
2186
+ entity: Entity;
2187
+ player: Player;
2188
+ raycastHit?: RaycastHit;
2189
+ };
2154
2190
  /** Emitted when the playback rate of the entity's model animations is set. */
2155
2191
  [EntityEvent.SET_MODEL_ANIMATIONS_PLAYBACK_RATE]: {
2156
2192
  entity: Entity;
@@ -4533,8 +4569,14 @@ export declare class Player extends EventRouter implements protocol.Serializable
4533
4569
 
4534
4570
 
4535
4571
 
4572
+
4573
+
4536
4574
  /** The current {@link PlayerInput} of the player. */
4537
4575
  get input(): PlayerInput;
4576
+ /** Whether the players click/taps will cause interacts with blocks or entities. Defaults to true. */
4577
+ get interactEnabled(): boolean;
4578
+ /** The maximum distance a player can interact with entities or blocks. The raycast distance in blocks for interactions. Defaults to 20. */
4579
+ get maxInteractDistance(): number;
4538
4580
  /** The current {@link World} the player is in. */
4539
4581
  get world(): World | undefined;
4540
4582
  /**
@@ -4588,6 +4630,16 @@ export declare class Player extends EventRouter implements protocol.Serializable
4588
4630
  * Resets all inputs keys
4589
4631
  */
4590
4632
  resetInputs(): void;
4633
+ /**
4634
+ * Sets whether the players click/taps will cause interacts with blocks or entities.
4635
+ * @param enabled - Whether the players click/taps will cause interacts with blocks or entities.
4636
+ */
4637
+ setInteractEnabled(enabled: boolean): void;
4638
+ /**
4639
+ * Sets the maximum distance a player can interact with entities or blocks.
4640
+ * @param distance - The maximum distance in blocks used for the interact raycast. Default is 20.
4641
+ */
4642
+ setMaxInteractDistance(distance: number): void;
4591
4643
  /**
4592
4644
  * Set the persisted data for the player. This data can
4593
4645
  * later be retrieved using {@link Player.getPersistedData},
@@ -4613,6 +4665,7 @@ export declare class Player extends EventRouter implements protocol.Serializable
4613
4665
 
4614
4666
 
4615
4667
 
4668
+
4616
4669
  }
4617
4670
 
4618
4671
  /**
@@ -4973,6 +5026,7 @@ export declare type PlayerEntityOptions = {
4973
5026
  /** Event types a Player can emit. See {@link PlayerEventPayloads} for the payloads. @public */
4974
5027
  export declare enum PlayerEvent {
4975
5028
  CHAT_MESSAGE_SEND = "PLAYER.CHAT_MESSAGE_SEND",
5029
+ INTERACT = "PLAYER.INTERACT",
4976
5030
  JOINED_WORLD = "PLAYER.JOINED_WORLD",
4977
5031
  LEFT_WORLD = "PLAYER.LEFT_WORLD",
4978
5032
  RECONNECTED_WORLD = "PLAYER.RECONNECTED_WORLD",
@@ -4992,6 +5046,13 @@ export declare interface PlayerEventPayloads {
4992
5046
  player: Player;
4993
5047
  world: World;
4994
5048
  };
5049
+ /** Emitted when a player interacts the world. */
5050
+ [PlayerEvent.INTERACT]: {
5051
+ player: Player;
5052
+ interactOrigin: Vector3Like;
5053
+ interactDirection: Vector3Like;
5054
+ raycastHit?: RaycastHit;
5055
+ };
4995
5056
  /** Emitted when a player leaves a world. */
4996
5057
  [PlayerEvent.LEFT_WORLD]: {
4997
5058
  player: Player;
@@ -5114,17 +5175,26 @@ export declare class PlayerUI extends EventRouter {
5114
5175
  /** The player that the UI belongs to. @readonly */
5115
5176
  readonly player: Player;
5116
5177
 
5178
+ /**
5179
+ * Freezes or unfreezes the player's pointer lock state. Preventing player inputs
5180
+ * from automatically locking or unlocking the pointer relative to its current state.
5181
+ * @param freeze - Set true to freeze the pointer lock state, false to unfreeze it.
5182
+ */
5183
+ freezePointerLock(freeze: boolean): void;
5117
5184
  /**
5118
5185
  * Loads client UI for the player.
5119
5186
  * @param htmlUri - The ui html uri to load.
5120
5187
  */
5121
5188
  load(htmlUri: string): void;
5122
5189
  /**
5123
- * Locks or unlocks the player's mouse pointer. If the pointer is unlocked
5124
- * with lockPointer(false), the player will not be able to use in-game inputs
5190
+ * Locks or unlocks the player's mouse pointer on Desktop. If the pointer is unlocked
5191
+ * with `lockPointer(false)`, the player will not be able to use in-game inputs
5125
5192
  * or camera controls from the mouse pointer until `player.ui.lockPointer(true)`,
5126
5193
  * or in your game's client UI html with `hytopia.lockPointer(true)`.
5127
5194
  *
5195
+ * @remarks
5196
+ * Pointer lock has no effect on mobile devices.
5197
+ *
5128
5198
  * @param lock - Set true to lock the pointer, false to unlock it.
5129
5199
  */
5130
5200
  lockPointer(lock: boolean): void;
@@ -5138,6 +5208,7 @@ export declare class PlayerUI extends EventRouter {
5138
5208
  /** Event types a PlayerUI can emit. See {@link PlayerUIEventPayloads} for the payloads. @public */
5139
5209
  export declare enum PlayerUIEvent {
5140
5210
  DATA = "PLAYER_UI.DATA",
5211
+ FREEZE_POINTER_LOCK = "PLAYER_UI.FREEZE_POINTER_LOCK",
5141
5212
  LOAD = "PLAYER_UI.LOAD",
5142
5213
  LOCK_POINTER = "PLAYER_UI.LOCK_POINTER",
5143
5214
  SEND_DATA = "PLAYER_UI.SEND_DATA"
@@ -5150,6 +5221,11 @@ export declare interface PlayerUIEventPayloads {
5150
5221
  playerUI: PlayerUI;
5151
5222
  data: Record<string, any>;
5152
5223
  };
5224
+ /** Emitted when the player's pointer lock is frozen or unfrozen. */
5225
+ [PlayerUIEvent.FREEZE_POINTER_LOCK]: {
5226
+ playerUI: PlayerUI;
5227
+ freeze: boolean;
5228
+ };
5153
5229
  /** Emitted when the player's client UI is loaded. */
5154
5230
  [PlayerUIEvent.LOAD]: {
5155
5231
  playerUI: PlayerUI;
@@ -5406,6 +5482,10 @@ export declare type RaycastHit = {
5406
5482
  hitPoint: Vector3Like;
5407
5483
  /** The distance from origin where the raycast hit. */
5408
5484
  hitDistance: number;
5485
+ /** The origin of the raycast. */
5486
+ origin: Vector3Like;
5487
+ /** The direction of the raycast from the origin. */
5488
+ originDirection: Vector3Like;
5409
5489
  };
5410
5490
 
5411
5491
  /** Options for raycasting. @public */
@@ -6287,7 +6367,7 @@ export declare interface SpdMatrix3 extends SdpMatrix3 {
6287
6367
  export declare function startServer(init: ((() => void) | ((world: World) => void))): void;
6288
6368
 
6289
6369
  /** The inputs that are included in the PlayerInput. @public */
6290
- export declare const SUPPORTED_INPUTS: readonly ["w", "a", "s", "d", "sp", "sh", "tb", "ml", "mr", "q", "e", "r", "f", "z", "x", "c", "v", "u", "i", "o", "j", "k", "l", "n", "m", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "cp", "cy", "jd"];
6370
+ export declare const SUPPORTED_INPUTS: readonly ["w", "a", "s", "d", "sp", "sh", "tb", "ml", "mr", "q", "e", "r", "f", "z", "x", "c", "v", "u", "i", "o", "j", "k", "l", "n", "m", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "cp", "cy", "iro", "ird", "jd"];
6291
6371
 
6292
6372
  /**
6293
6373
  * Manages performance telemetry and error tracking through your Sentry.io account.