Skip to content

Commit

Permalink
Support Device Changing
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyBananaGAME committed Oct 15, 2024
1 parent b76a2f9 commit 70d5dda
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sanctumterra/client",
"version": "2.1.3",
"version": "2.1.5",
"minecraft": "1.21.30",
"description": "We'll be singing Baraye.",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/client/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Authflow, Titles } from "prismarine-auth";
import { v3 } from "uuid-1345";
import { Logger } from "../vendor/Logger";
import type { Connection } from "../Connection";
import { measureExecutionTimeForFunction } from "src/vendor/debug-tools";
import { measureExecutionTimeForFunction } from "../vendor/debug-tools";

interface Profile {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/ClientData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ClientData {
DefaultInputMode: 1,
DeviceId: this.nextUUID(),
DeviceModel: "Helicopter",
DeviceOS: 7,
DeviceOS: this.client.options.deviceOS,
GameVersion: this.client.options.version,
GuiScale: 0,
IsEditorMode: false,
Expand Down
28 changes: 27 additions & 1 deletion src/client/ClientOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ enum ProtocolList {
"1.21.30" = 729,
}

enum DeviceOS {
Undefined = 0,
Android = 1,
IOS = 2,
OSX = 3,
FireOS = 4,
GearVR = 5,
Hololens = 6,
Win10 = 7,
Win32 = 8,
Dedicated = 9,
TVOS = 10,
Orbis = 11,
NintendoSwitch = 12,
Xbox = 13,
WindowsPhone = 14,
}

type RealmOptions = {
realmInvite: string;
};
Expand All @@ -20,6 +38,7 @@ type ClientOptions = {
tokensFolder: string;
viewDistance: number;
loadPlugins: boolean;
deviceOS: DeviceOS;
};

const defaultOptions: ClientOptions = {
Expand All @@ -33,6 +52,13 @@ const defaultOptions: ClientOptions = {
tokensFolder: `${process.cwd()}/tokens`,
viewDistance: 10,
loadPlugins: false,
deviceOS: DeviceOS.Win10,
};

export { type ClientOptions, type RealmOptions, defaultOptions, ProtocolList };
export {
type ClientOptions,
type RealmOptions,
defaultOptions,
ProtocolList,
DeviceOS,
};
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Client } from "./Client";
import { Logger } from "./vendor/Logger";
import { Connection } from "./Connection";
import { DeviceOS } from "./client/ClientOptions";

declare global {
var shieldID: number;
}

export { Client, Logger, Connection };
export * from "./vendor/debug-tools";
export { Client, Logger, Connection, DeviceOS };
3 changes: 2 additions & 1 deletion src/tools/offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type TextPacket,
type UpdateBlockPacket,
} from "@serenityjs/protocol";
import { Client, Logger } from "../index";
import { Client, DeviceOS, Logger } from "../index";

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

Expand All @@ -15,6 +15,7 @@ const client = new Client({
offline: true,
loadPlugins: false,
debug: false,
deviceOS: DeviceOS.Android,
});

client.raknet.socket.on("error", (error) => Logger.error(error));
Expand Down

0 comments on commit 70d5dda

Please sign in to comment.