Add interval property for configurable tick rate in LagoonAddons
This commit is contained in:
@@ -2,7 +2,7 @@ import { system, world } from "@minecraft/server";
|
|||||||
import utils from "utils";
|
import utils from "utils";
|
||||||
import { websocket } from "@minecraft/server-net";
|
import { websocket } from "@minecraft/server-net";
|
||||||
import { InitPlayer } from "entities/player";
|
import { InitPlayer } from "entities/player";
|
||||||
import { roomCode } from "properties";
|
import { interval, roomCode } from "properties";
|
||||||
class LagoonAddons {
|
class LagoonAddons {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.timer = 0;
|
this.timer = 0;
|
||||||
@@ -42,7 +42,7 @@ class LagoonAddons {
|
|||||||
async clock() {
|
async clock() {
|
||||||
this.timer++;
|
this.timer++;
|
||||||
// 1 seconde
|
// 1 seconde
|
||||||
if (this.timer % 20 === 0) {
|
if (this.timer % interval === 0) {
|
||||||
if (this.ws.isOpen) {
|
if (this.ws.isOpen) {
|
||||||
const players = world.getAllPlayers().map((p) => {
|
const players = world.getAllPlayers().map((p) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export const roomCode = 'ROOM_CODE';
|
export const roomCode = 'ROOM_CODE';
|
||||||
|
export const interval = 20; // Interval in ticks at which positions will be sent to the server. (Min: 10)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { system, world } from "@minecraft/server";
|
|||||||
import utils from "utils";
|
import utils from "utils";
|
||||||
import { websocket, WebSocketClient } from "@minecraft/server-net";
|
import { websocket, WebSocketClient } from "@minecraft/server-net";
|
||||||
import { InitPlayer } from "entities/player";
|
import { InitPlayer } from "entities/player";
|
||||||
import { roomCode } from "properties";
|
import { interval, roomCode } from "properties";
|
||||||
|
|
||||||
class LagoonAddons {
|
class LagoonAddons {
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class LagoonAddons {
|
|||||||
this.timer++;
|
this.timer++;
|
||||||
|
|
||||||
// 1 seconde
|
// 1 seconde
|
||||||
if (this.timer % 20 === 0) {
|
if (this.timer % interval === 0) {
|
||||||
|
|
||||||
if (this.ws.isOpen) {
|
if (this.ws.isOpen) {
|
||||||
const players: {x: number, y: number, z: number, code: string, muted: boolean}[] = world.getAllPlayers().map((p) => {
|
const players: {x: number, y: number, z: number, code: string, muted: boolean}[] = world.getAllPlayers().map((p) => {
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export const roomCode = 'ROOM_CODE';
|
export const roomCode = 'ROOM_CODE';
|
||||||
|
export const interval = 20; // Interval in ticks at which positions will be sent to the server. (Min: 10)
|
||||||
Reference in New Issue
Block a user