convert whole project to use default exports
This commit is contained in:
parent
7d4445112b
commit
78c894a94d
90 changed files with 386 additions and 377 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { SaveCompressionType } from "./server/enums/SaveCompressionType";
|
import SaveCompressionType from "./server/enums/SaveCompressionType";
|
||||||
|
|
||||||
export interface Config {
|
export default interface Config {
|
||||||
port: number,
|
port: number,
|
||||||
maxPlayers: number,
|
maxPlayers: number,
|
||||||
seed: number|string,
|
seed: number|string,
|
||||||
|
|
9
index.ts
9
index.ts
|
@ -1,8 +1,9 @@
|
||||||
import { Config } from "./config";
|
|
||||||
import { Console } from "hsconsole";
|
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import { MinecraftServer } from "./server/MinecraftServer";
|
import { Console } from "hsconsole";
|
||||||
import { SaveCompressionType } from "./server/enums/SaveCompressionType";
|
import Config from "./config";
|
||||||
|
import MinecraftServer from "./server/MinecraftServer";
|
||||||
|
import SaveCompressionType from "./server/enums/SaveCompressionType";
|
||||||
|
|
||||||
const tempConfig = JSON.parse(readFileSync("./config.json").toString());
|
const tempConfig = JSON.parse(readFileSync("./config.json").toString());
|
||||||
tempConfig.saveCompression = SaveCompressionType[tempConfig.saveCompression];
|
tempConfig.saveCompression = SaveCompressionType[tempConfig.saveCompression];
|
||||||
const config:Config = tempConfig as Config;
|
const config:Config = tempConfig as Config;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export class NibbleArray {
|
export default class NibbleArray {
|
||||||
private array:Uint8Array;
|
private array:Uint8Array;
|
||||||
|
|
||||||
public constructor(size:number|ArrayBuffer|Uint8Array) {
|
public constructor(size:number|ArrayBuffer|Uint8Array) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
import Block from "./blocks/Block";
|
||||||
import FunkyArray from "funky-array";
|
import FunkyArray from "funky-array";
|
||||||
import { NibbleArray } from "../nibbleArray";
|
import NibbleArray from "../nibbleArray";
|
||||||
import { Block } from "./blocks/Block";
|
import Player from "./entities/Player";
|
||||||
import { Player } from "./entities/Player";
|
import QueuedBlockUpdate from "./queuedUpdateTypes/BlockUpdate";
|
||||||
import { QueuedBlockUpdate } from "./queuedUpdateTypes/BlockUpdate";
|
import World from "./World";
|
||||||
import { World } from "./World";
|
|
||||||
|
|
||||||
export class Chunk {
|
export default class Chunk {
|
||||||
private readonly MAX_HEIGHT:number = 128;
|
private readonly MAX_HEIGHT:number = 128;
|
||||||
private readonly FULLBRIGHT = false;
|
private readonly FULLBRIGHT = false;
|
||||||
public readonly world:World;
|
public readonly world:World;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { MetadataEntry, MetadataWriter } from "./MetadataWriter";
|
import { MetadataEntry, MetadataWriter } from "./MetadataWriter";
|
||||||
import { MetadataFieldType } from "./enums/MetadataFieldType";
|
import MetadataFieldType from "./enums/MetadataFieldType";
|
||||||
|
|
||||||
export default class EntityMetadata {
|
export default class EntityMetadata {
|
||||||
public onFire:boolean = false;
|
public onFire:boolean = false;
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
import { Console } from "hsconsole";
|
|
||||||
import { IReader } from "bufferstuff";
|
import { IReader } from "bufferstuff";
|
||||||
import { MinecraftServer } from "./MinecraftServer";
|
import { Console } from "hsconsole";
|
||||||
import { Packet } from "./enums/Packet";
|
|
||||||
import { PacketAnimation } from "./packets/Animation";
|
|
||||||
import { PacketChat } from "./packets/Chat"
|
|
||||||
import { PacketEntityAction } from "./packets/EntityAction";
|
|
||||||
import { PacketPlayer } from "./packets/Player";
|
|
||||||
import { PacketPlayerPosition } from "./packets/PlayerPosition";
|
|
||||||
import { PacketPlayerLook } from "./packets/PlayerLook";
|
|
||||||
import { PacketPlayerPositionLook } from "./packets/PlayerPositionLook";
|
|
||||||
import { PacketPlayerDigging } from "./packets/PlayerDigging";
|
|
||||||
import { Player } from "./entities/Player";
|
|
||||||
import { Socket } from "net";
|
import { Socket } from "net";
|
||||||
import Vec3 from "./Vec3";
|
|
||||||
import { PacketRespawn } from "./packets/Respawn";
|
|
||||||
import { PacketPlayerBlockPlacement } from "./packets/PlayerBlockPlacement";
|
|
||||||
import { PacketHoldingChange } from "./packets/HoldingChange";
|
|
||||||
import { PacketDisconnectKick } from "./packets/DisconnectKick";
|
|
||||||
import { ItemStack } from "./inventories/ItemStack";
|
|
||||||
import { Block } from "./blocks/Block";
|
|
||||||
import { EntityItem } from "./entities/EntityItem";
|
|
||||||
import AABB from "./AABB";
|
import AABB from "./AABB";
|
||||||
import { PacketSoundEffect } from "./packets/SoundEffect";
|
import Block from "./blocks/Block";
|
||||||
import { SoundEffects } from "./enums/SoundEffects";
|
import EntityLiving from "./entities/EntityLiving";
|
||||||
import { PacketUseEntity } from "./packets/UseEntity";
|
import EntityItem from "./entities/EntityItem";
|
||||||
import { EntityLiving } from "./entities/EntityLiving";
|
import ItemStack from "./inventories/ItemStack";
|
||||||
|
import MinecraftServer from "./MinecraftServer";
|
||||||
|
import Packet from "./enums/Packet";
|
||||||
|
import PacketAnimation from "./packets/Animation";
|
||||||
|
import PacketChat from "./packets/Chat"
|
||||||
|
import PacketEntityAction from "./packets/EntityAction";
|
||||||
|
import PacketPlayer from "./packets/Player";
|
||||||
|
import PacketPlayerPosition from "./packets/PlayerPosition";
|
||||||
|
import PacketPlayerLook from "./packets/PlayerLook";
|
||||||
|
import PacketPlayerPositionLook from "./packets/PlayerPositionLook";
|
||||||
|
import PacketPlayerDigging from "./packets/PlayerDigging";
|
||||||
|
import PacketRespawn from "./packets/Respawn";
|
||||||
|
import PacketPlayerBlockPlacement from "./packets/PlayerBlockPlacement";
|
||||||
|
import PacketHoldingChange from "./packets/HoldingChange";
|
||||||
|
import PacketDisconnectKick from "./packets/DisconnectKick";
|
||||||
|
import PacketSoundEffect from "./packets/SoundEffect";
|
||||||
|
import PacketUseEntity from "./packets/UseEntity";
|
||||||
|
import Player from "./entities/Player";
|
||||||
import PlayerInventory from "./inventories/PlayerInventory";
|
import PlayerInventory from "./inventories/PlayerInventory";
|
||||||
|
import SoundEffects from "./enums/SoundEffects";
|
||||||
|
import Vec3 from "./Vec3";
|
||||||
|
|
||||||
export class MPClient {
|
export default class MPClient {
|
||||||
private readonly mcServer:MinecraftServer;
|
private readonly mcServer:MinecraftServer;
|
||||||
private readonly socket:Socket;
|
private readonly socket:Socket;
|
||||||
public entity:Player;
|
public entity:Player;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, Endian } from "bufferstuff";
|
import { createWriter, Endian } from "bufferstuff";
|
||||||
import FunkyArray from "funky-array";
|
import FunkyArray from "funky-array";
|
||||||
import { MetadataFieldType } from "./enums/MetadataFieldType";
|
import ItemStack from "./inventories/ItemStack";
|
||||||
|
import MetadataFieldType from "./enums/MetadataFieldType";
|
||||||
import Vec3 from "./Vec3";
|
import Vec3 from "./Vec3";
|
||||||
import { ItemStack } from "./inventories/ItemStack";
|
|
||||||
|
|
||||||
export class MetadataEntry {
|
export class MetadataEntry {
|
||||||
public type:MetadataFieldType;
|
public type:MetadataFieldType;
|
||||||
|
|
|
@ -1,29 +1,28 @@
|
||||||
import { Config } from "../config";
|
|
||||||
import { Console } from "hsconsole";
|
|
||||||
import { createReader, IReader, Endian } from "bufferstuff";
|
import { createReader, IReader, Endian } from "bufferstuff";
|
||||||
import FunkyArray from "funky-array";
|
|
||||||
import { Server, Socket } from "net";
|
|
||||||
import { MPClient } from "./MPClient";
|
|
||||||
import { Packet } from "./enums/Packet";
|
|
||||||
import { PacketKeepAlive } from "./packets/KeepAlive";
|
|
||||||
import { PacketHandshake } from "./packets/Handshake";
|
|
||||||
import { PacketLoginRequest } from "./packets/LoginRequest";
|
|
||||||
import { PacketChat } from "./packets/Chat";
|
|
||||||
import { PacketSpawnPosition } from "./packets/SpawnPosition";
|
|
||||||
import { PacketPlayerPositionLook } from "./packets/PlayerPositionLook";
|
|
||||||
import { PacketNamedEntitySpawn } from "./packets/NamedEntitySpawn";
|
|
||||||
import { PacketDisconnectKick } from "./packets/DisconnectKick";
|
|
||||||
import { Player } from "./entities/Player";
|
|
||||||
import { SaveCompressionType } from "./enums/SaveCompressionType";
|
|
||||||
import { WorldSaveManager } from "./WorldSaveManager";
|
|
||||||
import { World } from "./World";
|
|
||||||
import { Chunk } from "./Chunk";
|
|
||||||
import { PacketTimeUpdate } from "./packets/TimeUpdate";
|
|
||||||
import { HillyGenerator } from "./generators/Hilly";
|
|
||||||
import { NetherGenerator } from "./generators/Nether";
|
|
||||||
import { PacketWindowItems } from "./packets/WindowItems";
|
|
||||||
import { getRandomValues } from "crypto";
|
import { getRandomValues } from "crypto";
|
||||||
import { NewOverworld } from "./generators/NewOverworld";
|
import { Console } from "hsconsole";
|
||||||
|
import { Server, Socket } from "net";
|
||||||
|
import Config from "../config";
|
||||||
|
import Chunk from "./Chunk";
|
||||||
|
import FunkyArray from "funky-array";
|
||||||
|
import HillyGenerator from "./generators/terrain/Hilly";
|
||||||
|
import MPClient from "./MPClient";
|
||||||
|
import NetherGenerator from "./generators/terrain/Nether";
|
||||||
|
import Packet from "./enums/Packet";
|
||||||
|
import PacketKeepAlive from "./packets/KeepAlive";
|
||||||
|
import PacketHandshake from "./packets/Handshake";
|
||||||
|
import PacketLoginRequest from "./packets/LoginRequest";
|
||||||
|
import PacketChat from "./packets/Chat";
|
||||||
|
import PacketSpawnPosition from "./packets/SpawnPosition";
|
||||||
|
import PacketPlayerPositionLook from "./packets/PlayerPositionLook";
|
||||||
|
import PacketNamedEntitySpawn from "./packets/NamedEntitySpawn";
|
||||||
|
import PacketDisconnectKick from "./packets/DisconnectKick";
|
||||||
|
import PacketTimeUpdate from "./packets/TimeUpdate";
|
||||||
|
import PacketWindowItems from "./packets/WindowItems";
|
||||||
|
import Player from "./entities/Player";
|
||||||
|
import SaveCompressionType from "./enums/SaveCompressionType";
|
||||||
|
import World from "./World";
|
||||||
|
import WorldSaveManager from "./WorldSaveManager";
|
||||||
|
|
||||||
const chunkFrom = -15;
|
const chunkFrom = -15;
|
||||||
const chunkTo = 15;
|
const chunkTo = 15;
|
||||||
|
@ -34,7 +33,7 @@ function getRandomSeed() {
|
||||||
return getRandomValues(arr)[0];
|
return getRandomValues(arr)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MinecraftServer {
|
export default class MinecraftServer {
|
||||||
private static readonly PROTOCOL_VERSION = 14;
|
private static readonly PROTOCOL_VERSION = 14;
|
||||||
private static readonly TICK_RATE = 20;
|
private static readonly TICK_RATE = 20;
|
||||||
private static readonly TICK_RATE_MS = 1000 / MinecraftServer.TICK_RATE;
|
private static readonly TICK_RATE_MS = 1000 / MinecraftServer.TICK_RATE;
|
||||||
|
@ -83,6 +82,7 @@ export class MinecraftServer {
|
||||||
// Save chunks
|
// Save chunks
|
||||||
Console.printInfo("Saving worlds...");
|
Console.printInfo("Saving worlds...");
|
||||||
// There's a race condition here. oops.
|
// There's a race condition here. oops.
|
||||||
|
const keepRunningInterval = setInterval(() => {}, 1000);
|
||||||
let savedWorldCount = 0;
|
let savedWorldCount = 0;
|
||||||
let savedChunkCount = 0;
|
let savedChunkCount = 0;
|
||||||
await this.worlds.forEach(async (world) => {
|
await this.worlds.forEach(async (world) => {
|
||||||
|
@ -101,6 +101,7 @@ export class MinecraftServer {
|
||||||
|
|
||||||
// hsconsole is gone now so we have to use built in.
|
// hsconsole is gone now so we have to use built in.
|
||||||
console.log("Goodbye");
|
console.log("Goodbye");
|
||||||
|
clearInterval(keepRunningInterval);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.config.saveCompression === SaveCompressionType.NONE) {
|
if (this.config.saveCompression === SaveCompressionType.NONE) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Vec2 } from "./Vec2";
|
import Vec2 from "./Vec2";
|
||||||
|
|
||||||
export class Rotation extends Vec2 {
|
export default class Rotation extends Vec2 {
|
||||||
public get yaw() {
|
public get yaw() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export class TrackedProperty<T> {
|
export default class TrackedProperty<T> {
|
||||||
private trackedValue?:T;
|
private trackedValue?:T;
|
||||||
private updateCallback?:(value:T) => void;
|
private updateCallback?:(value:T) => void;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export class Vec2 {
|
export default class Vec2 {
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
import { Endian, createWriter } from "bufferstuff";
|
import { Endian, createWriter } from "bufferstuff";
|
||||||
import FunkyArray from "funky-array";
|
|
||||||
import { Chunk } from "./Chunk";
|
|
||||||
import { WorldSaveManager } from "./WorldSaveManager";
|
|
||||||
import { Block } from "./blocks/Block";
|
|
||||||
import { EntityItem } from "./entities/EntityItem";
|
|
||||||
import { IEntity } from "./entities/IEntity";
|
|
||||||
import { Player } from "./entities/Player";
|
|
||||||
//import { FlatGenerator } from "./generators/Flat";
|
|
||||||
import { HillyGenerator } from "./generators/Hilly";
|
|
||||||
import { IGenerator } from "./generators/IGenerator";
|
|
||||||
import { PacketBlockChange } from "./packets/BlockChange";
|
|
||||||
import { PacketDestroyEntity } from "./packets/DestroyEntity";
|
|
||||||
import { PacketPickupSpawn } from "./packets/PickupSpawn";
|
|
||||||
import { QueuedBlockUpdate } from "./queuedUpdateTypes/BlockUpdate";
|
|
||||||
import { IQueuedUpdate } from "./queuedUpdateTypes/IQueuedUpdate";
|
|
||||||
import AABB from "./AABB";
|
import AABB from "./AABB";
|
||||||
|
import Block from "./blocks/Block";
|
||||||
|
import Chunk from "./Chunk";
|
||||||
|
import EntityItem from "./entities/EntityItem";
|
||||||
|
import FunkyArray from "funky-array";
|
||||||
|
import IEntity from "./entities/IEntity";
|
||||||
|
import IGenerator from "./generators/IGenerator";
|
||||||
|
import IQueuedUpdate from "./queuedUpdateTypes/IQueuedUpdate";
|
||||||
|
import PacketBlockChange from "./packets/BlockChange";
|
||||||
|
import PacketDestroyEntity from "./packets/DestroyEntity";
|
||||||
|
import PacketPickupSpawn from "./packets/PickupSpawn";
|
||||||
|
import Player from "./entities/Player";
|
||||||
|
import QueuedBlockUpdate from "./queuedUpdateTypes/BlockUpdate";
|
||||||
import Random from "./Random";
|
import Random from "./Random";
|
||||||
|
import WorldSaveManager from "./WorldSaveManager";
|
||||||
|
|
||||||
export class World {
|
export default class World {
|
||||||
public static ENTITY_MAX_SEND_DISTANCE = 50;
|
public static ENTITY_MAX_SEND_DISTANCE = 50;
|
||||||
private static READ_CHUNKS_FROM_DISK = true;
|
private static READ_CHUNKS_FROM_DISK = true;
|
||||||
|
|
||||||
|
@ -198,7 +196,7 @@ export class World {
|
||||||
chunk.setBlockWithMetadata(blockId, metadata, x & 0xf, y, z & 0xf);
|
chunk.setBlockWithMetadata(blockId, metadata, x & 0xf, y, z & 0xf);
|
||||||
|
|
||||||
if (doBlockUpdate) {
|
if (doBlockUpdate) {
|
||||||
const blockUpdatePacket = new PacketBlockChange(x, y, z, blockId, metadata).writeData(); // TODO: Handle metadata
|
const blockUpdatePacket = new PacketBlockChange(x, y, z, blockId, metadata).writeData();
|
||||||
// Send block update to all players that have this chunk loaded
|
// Send block update to all players that have this chunk loaded
|
||||||
chunk.playersInChunk.forEach(player => {
|
chunk.playersInChunk.forEach(player => {
|
||||||
player.mpClient?.send(blockUpdatePacket);
|
player.mpClient?.send(blockUpdatePacket);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { readFileSync, readFile, writeFile, existsSync, mkdirSync, writeFileSync, readdirSync, renameSync } from "fs";
|
|
||||||
import { createWriter, createReader, Endian, IWriter, IReader } from "bufferstuff";
|
import { createWriter, createReader, Endian, IWriter, IReader } from "bufferstuff";
|
||||||
import { Config } from "../config";
|
import { readFileSync, readFile, writeFile, existsSync, mkdirSync, writeFileSync, readdirSync, renameSync } from "fs";
|
||||||
import { Chunk } from "./Chunk";
|
|
||||||
import { SaveCompressionType } from "./enums/SaveCompressionType";
|
|
||||||
import { deflate, inflate } from "zlib";
|
|
||||||
import { World } from "./World";
|
|
||||||
import FunkyArray from "funky-array";
|
|
||||||
import { Console } from "hsconsole";
|
import { Console } from "hsconsole";
|
||||||
|
import { deflate, inflate } from "zlib";
|
||||||
|
import Chunk from "./Chunk";
|
||||||
|
import Config from "../config";
|
||||||
|
import FunkyArray from "funky-array";
|
||||||
|
import SaveCompressionType from "./enums/SaveCompressionType";
|
||||||
|
import World from "./World";
|
||||||
|
|
||||||
enum FileMagic {
|
enum FileMagic {
|
||||||
Chunk = 0xFC,
|
Chunk = 0xFC,
|
||||||
|
@ -14,7 +14,7 @@ enum FileMagic {
|
||||||
Player = 0xFE
|
Player = 0xFE
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WorldSaveManager {
|
export default class WorldSaveManager {
|
||||||
private readonly worldFolderPath;
|
private readonly worldFolderPath;
|
||||||
private readonly globalDataPath;
|
private readonly globalDataPath;
|
||||||
private readonly worldPlayerDataFolderPath;
|
private readonly worldPlayerDataFolderPath;
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
import { World } from "../World";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviourSapling } from "./BlockBehaviorSapling";
|
import BlockBehaviourSapling from "./BlockBehaviorSapling";
|
||||||
import { BlockBehaviourSugarcane } from "./BlockBehaviorSugarcane";
|
import BlockBehaviourSugarcane from "./BlockBehaviorSugarcane";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import BlockBehaviourClay from "./BlockBehaviourClay";
|
||||||
import { BlockBehaviourClay } from "./BlockBehaviourClay";
|
import BlockBehaviourFlower from "./BlockBehaviourFlower";
|
||||||
import { BlockBehaviourFlower } from "./BlockBehaviourFlower";
|
import BlockBehaviourGrass from "./BlockBehaviourGrass";
|
||||||
import { BlockBehaviourGrass } from "./BlockBehaviourGrass";
|
|
||||||
import BlockBehaviourOre from "./BlockBehaviourOre";
|
import BlockBehaviourOre from "./BlockBehaviourOre";
|
||||||
import BlockBehaviourRedstoneOre from "./BlockBehaviourRedstoneOre";
|
import BlockBehaviourRedstoneOre from "./BlockBehaviourRedstoneOre";
|
||||||
import { BlockBehaviourStone } from "./BlockBehaviourStone";
|
import BlockBehaviourStone from "./BlockBehaviourStone";
|
||||||
import { BlockBehaviourTallGrass } from "./BlockBehaviourTallGrass";
|
import BlockBehaviourTallGrass from "./BlockBehaviourTallGrass";
|
||||||
import { IBlockBehaviour } from "./IBlockBehaviour";
|
import IBlockBehaviour from "./IBlockBehaviour";
|
||||||
|
import World from "../World";
|
||||||
|
|
||||||
abstract class Behaviour {
|
abstract class Behaviour {
|
||||||
public static base = new BlockBehaviour();
|
public static base = new BlockBehaviour();
|
||||||
|
@ -29,7 +29,7 @@ abstract class Behaviour {
|
||||||
public static sugarcane = new BlockBehaviourSugarcane();
|
public static sugarcane = new BlockBehaviourSugarcane();
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Block {
|
export default class Block {
|
||||||
public readonly blockId:number;
|
public readonly blockId:number;
|
||||||
|
|
||||||
public static readonly blocks:Array<Block> = new Array<Block>();
|
public static readonly blocks:Array<Block> = new Array<Block>();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import Random from "../Random";
|
import Random from "../Random";
|
||||||
import { World } from "../World";
|
import World from "../World";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
|
||||||
|
|
||||||
export class BlockBehaviourSapling extends BlockBehaviour {
|
export default class BlockBehaviourSapling extends BlockBehaviour {
|
||||||
public randomTick(world:World, x:number, y:number, z:number, random:Random) {
|
public randomTick(world:World, x:number, y:number, z:number, random:Random) {
|
||||||
if (world.getBlockLight(x, y + 1, z) >= 9 && random.nextInt(30) === 0) {
|
if (world.getBlockLight(x, y + 1, z) >= 9 && random.nextInt(30) === 0) {
|
||||||
const blockMetadata = world.getBlockMetadata(x, y, z);
|
const blockMetadata = world.getBlockMetadata(x, y, z);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
import { World } from "../World";
|
import Block from "./Block";
|
||||||
import { Block } from "./Block";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import World from "../World";
|
||||||
|
|
||||||
export class BlockBehaviourSugarcane extends BlockBehaviour {
|
export default class BlockBehaviourSugarcane extends BlockBehaviour {
|
||||||
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
||||||
const block = world.getBlockId(x, y - 1, z);
|
const block = world.getBlockId(x, y - 1, z);
|
||||||
if (block === 0 || block !== Block.sugarcane.blockId) {
|
if (block === 0 || block !== Block.sugarcane.blockId) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
|
import Block from "./Block";
|
||||||
|
import IBlockBehaviour from "./IBlockBehaviour";
|
||||||
import Random from "../Random";
|
import Random from "../Random";
|
||||||
import { World } from "../World";
|
import World from "../World";
|
||||||
import { Block } from "./Block";
|
|
||||||
import { IBlockBehaviour } from "./IBlockBehaviour";
|
|
||||||
|
|
||||||
export class BlockBehaviour implements IBlockBehaviour {
|
export default class BlockBehaviour implements IBlockBehaviour {
|
||||||
public block!:Block;
|
public block!:Block;
|
||||||
|
|
||||||
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {}
|
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Item } from "../items/Item";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import Item from "../items/Item";
|
||||||
|
|
||||||
export class BlockBehaviourClay extends BlockBehaviour {
|
export default class BlockBehaviourClay extends BlockBehaviour {
|
||||||
public droppedItem(blockId:number) {
|
public droppedItem(blockId:number) {
|
||||||
return Item.clay.shiftedItemID;
|
return Item.clay.shiftedItemID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
import { World } from "../World";
|
import Block from "./Block";
|
||||||
import { Block } from "./Block";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import World from "../World";
|
||||||
|
|
||||||
export class BlockBehaviourFlower extends BlockBehaviour {
|
export default class BlockBehaviourFlower extends BlockBehaviour {
|
||||||
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
||||||
const block = world.getBlockId(x, y - 1, z);
|
const block = world.getBlockId(x, y - 1, z);
|
||||||
if (block !== Block.grass.blockId && block !== Block.dirt.blockId) {
|
if (block !== Block.grass.blockId && block !== Block.dirt.blockId) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Block } from "./Block";
|
import Block from "./Block";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
|
|
||||||
export class BlockBehaviourGrass extends BlockBehaviour {
|
export default class BlockBehaviourGrass extends BlockBehaviour {
|
||||||
public droppedItem(blockId:number) {
|
public droppedItem(blockId:number) {
|
||||||
return Block.dirt.blockId;
|
return Block.dirt.blockId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Item } from "../items/Item";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import Item from "../items/Item";
|
||||||
|
|
||||||
export default class BlockBehaviourOre extends BlockBehaviour {
|
export default class BlockBehaviourOre extends BlockBehaviour {
|
||||||
public droppedItem(blockId:number) {
|
public droppedItem(blockId:number) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Item } from "../items/Item";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import Item from "../items/Item";
|
||||||
|
|
||||||
export default class BlockBehaviourRedstoneOre extends BlockBehaviour {
|
export default class BlockBehaviourRedstoneOre extends BlockBehaviour {
|
||||||
public droppedItem(blockId:number) {
|
public droppedItem(blockId:number) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Block } from "./Block";
|
import Block from "./Block";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
|
|
||||||
export class BlockBehaviourStone extends BlockBehaviour {
|
export default class BlockBehaviourStone extends BlockBehaviour {
|
||||||
public droppedItem(blockId:number) {
|
public droppedItem(blockId:number) {
|
||||||
return Block.cobblestone.blockId;
|
return Block.cobblestone.blockId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
import { World } from "../World";
|
import Block from "./Block";
|
||||||
import { Block } from "./Block";
|
import BlockBehaviour from "./BlockBehaviour";
|
||||||
import { BlockBehaviour } from "./BlockBehaviour";
|
import World from "../World";
|
||||||
|
|
||||||
export class BlockBehaviourTallGrass extends BlockBehaviour {
|
export default class BlockBehaviourTallGrass extends BlockBehaviour {
|
||||||
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {
|
||||||
const block = world.getBlockId(x, y - 1, z);
|
const block = world.getBlockId(x, y - 1, z);
|
||||||
if (block !== Block.grass.blockId && block !== Block.dirt.blockId) {
|
if (block !== Block.grass.blockId && block !== Block.dirt.blockId) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import AABB from "../AABB";
|
import AABB from "../AABB";
|
||||||
|
import Block from "./Block";
|
||||||
import Random from "../Random";
|
import Random from "../Random";
|
||||||
import { World } from "../World";
|
import World from "../World";
|
||||||
import { Block } from "./Block";
|
|
||||||
|
|
||||||
export interface IBlockBehaviour {
|
export default interface IBlockBehaviour {
|
||||||
block:Block,
|
block:Block,
|
||||||
|
|
||||||
neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number): void,
|
neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number): void,
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import { Endian, IReader, IWriter, createWriter } from "bufferstuff";
|
import { IReader, IWriter } from "bufferstuff";
|
||||||
import AABB from "../AABB";
|
|
||||||
import { Chunk } from "../Chunk";
|
|
||||||
import { MetadataEntry, MetadataWriter } from "../MetadataWriter";
|
import { MetadataEntry, MetadataWriter } from "../MetadataWriter";
|
||||||
import { Rotation } from "../Rotation";
|
import AABB from "../AABB";
|
||||||
import { Vec2 } from "../Vec2";
|
import Block from "../blocks/Block";
|
||||||
|
import Chunk from "../Chunk";
|
||||||
|
import IEntity from "./IEntity";
|
||||||
|
import MetadataFieldType from "../enums/MetadataFieldType";
|
||||||
|
import PacketEntityLook from "../packets/EntityLook";
|
||||||
|
import PacketEntityLookRelativeMove from "../packets/EntityLookRelativeMove";
|
||||||
|
import PacketEntityMetadata from "../packets/EntityMetadata";
|
||||||
|
import PacketEntityRelativeMove from "../packets/EntityRelativeMove";
|
||||||
|
import PacketEntityTeleport from "../packets/EntityTeleport";
|
||||||
|
import PacketEntityVelocity from "../packets/EntityVelocity";
|
||||||
|
import Player from "./Player";
|
||||||
|
import Rotation from "../Rotation";
|
||||||
|
import Vec2 from "../Vec2";
|
||||||
import Vec3 from "../Vec3";
|
import Vec3 from "../Vec3";
|
||||||
import { World } from "../World";
|
import World from "../World";
|
||||||
import { Block } from "../blocks/Block";
|
|
||||||
import { MetadataFieldType } from "../enums/MetadataFieldType";
|
|
||||||
import { PacketEntityLook } from "../packets/EntityLook";
|
|
||||||
import { PacketEntityLookRelativeMove } from "../packets/EntityLookRelativeMove";
|
|
||||||
import { PacketEntityMetadata } from "../packets/EntityMetadata";
|
|
||||||
import { PacketEntityRelativeMove } from "../packets/EntityRelativeMove";
|
|
||||||
import { PacketEntityTeleport } from "../packets/EntityTeleport";
|
|
||||||
import { PacketEntityVelocity } from "../packets/EntityVelocity";
|
|
||||||
import { IEntity } from "./IEntity";
|
|
||||||
import { Player } from "./Player";
|
|
||||||
|
|
||||||
export class Entity implements IEntity {
|
export default class Entity implements IEntity {
|
||||||
public static nextEntityId:number = 0;
|
public static nextEntityId:number = 0;
|
||||||
|
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
|
@ -193,11 +193,11 @@ export class Entity implements IEntity {
|
||||||
private sendPositionUpdate() {
|
private sendPositionUpdate() {
|
||||||
this.absPosition.set(Math.floor(this.position.x * 32), Math.floor(this.position.y * 32), Math.floor(this.position.z * 32));
|
this.absPosition.set(Math.floor(this.position.x * 32), Math.floor(this.position.y * 32), Math.floor(this.position.z * 32));
|
||||||
|
|
||||||
// This code *does* work, and it works well. But this is absolutely TERRIBLE!
|
const yaw = this.rotation.yaw / 256 * 180;
|
||||||
// There is definitely a better way to do this.
|
const pitch = this.rotation.pitch / 256 * 180;
|
||||||
this.absRotation.set(
|
this.absRotation.set(
|
||||||
this.constrainRot(Math.floor(((this.rotation.yaw - 180 >= 0 ? this.rotation.yaw - 180 : (this.rotation.yaw - 180) % 360 + 360) % 360 / 360) * 256) - 128), // Yaw
|
Math.floor(yaw - Math.floor((yaw + 128) / 256) * 256),
|
||||||
this.constrainRot(Math.floor((this.rotation.pitch % 360 * 256) / 360)) // Pitch
|
Math.floor(pitch - Math.floor((pitch + 128) / 256) * 256)
|
||||||
);
|
);
|
||||||
const diffX = this.absPosition.x - this.lastAbsPosition.x;
|
const diffX = this.absPosition.x - this.lastAbsPosition.x;
|
||||||
const diffY = this.absPosition.y - this.lastAbsPosition.y;
|
const diffY = this.absPosition.y - this.lastAbsPosition.y;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { World } from "../World";
|
import Entity from "./Entity";
|
||||||
import { ItemStack } from "../inventories/ItemStack";
|
import ItemStack from "../inventories/ItemStack";
|
||||||
import { Entity } from "./Entity";
|
import World from "../World";
|
||||||
import { Player } from "./Player";
|
|
||||||
|
|
||||||
export class EntityItem extends Entity {
|
export default class EntityItem extends Entity {
|
||||||
public age:number;
|
public age:number;
|
||||||
public itemStack:ItemStack;
|
public itemStack:ItemStack;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { IReader, IWriter } from "bufferstuff";
|
import { IReader, IWriter } from "bufferstuff";
|
||||||
import { World } from "../World";
|
import Block from "../blocks/Block";
|
||||||
import { Block } from "../blocks/Block";
|
import Entity from "./Entity";
|
||||||
import { EntityStatus } from "../enums/EntityStatus";
|
import EntityStatus from "../enums/EntityStatus";
|
||||||
import { PacketEntityStatus } from "../packets/EntityStatus";
|
import IEntity from "./IEntity";
|
||||||
import { Entity } from "./Entity";
|
import PacketEntityStatus from "../packets/EntityStatus";
|
||||||
import { IEntity } from "./IEntity";
|
import World from "../World";
|
||||||
|
|
||||||
export class EntityLiving extends Entity {
|
export default class EntityLiving extends Entity {
|
||||||
public timeInWater:number;
|
public timeInWater:number;
|
||||||
public headHeight:number;
|
public headHeight:number;
|
||||||
public lastHealth:number;
|
public lastHealth:number;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import AABB from "../AABB"
|
import AABB from "../AABB"
|
||||||
import Vec3 from "../Vec3"
|
import Vec3 from "../Vec3"
|
||||||
|
|
||||||
export interface IEntity {
|
export default interface IEntity {
|
||||||
entityId:number,
|
entityId:number,
|
||||||
position:Vec3,
|
position:Vec3,
|
||||||
motion:Vec3,
|
motion:Vec3,
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
import { Chunk } from "../Chunk";
|
|
||||||
import { MPClient } from "../MPClient";
|
|
||||||
import { MinecraftServer } from "../MinecraftServer";
|
|
||||||
import { World } from "../World";
|
|
||||||
import { PacketMapChunk } from "../packets/MapChunk";
|
|
||||||
import { EntityLiving } from "./EntityLiving";
|
|
||||||
import { PacketPreChunk } from "../packets/PreChunk";
|
|
||||||
import { PacketUpdateHealth } from "../packets/UpdateHealth";
|
|
||||||
import { Inventory } from "../inventories/Inventory";
|
|
||||||
import { ItemStack } from "../inventories/ItemStack";
|
|
||||||
import { Block } from "../blocks/Block";
|
|
||||||
import PlayerInventory from "../inventories/PlayerInventory";
|
|
||||||
import { Item } from "../items/Item";
|
|
||||||
import { PacketEntityEquipment } from "../packets/EntityEquipment";
|
|
||||||
import { IReader, IWriter } from "bufferstuff";
|
import { IReader, IWriter } from "bufferstuff";
|
||||||
import { EntityItem } from "./EntityItem";
|
import Block from "../blocks/Block";
|
||||||
import { Entity } from "./Entity";
|
import Chunk from "../Chunk";
|
||||||
import { PacketCollectItem } from "../packets/CollectItem";
|
import Entity from "./Entity";
|
||||||
import { PacketPickupSpawn } from "../packets/PickupSpawn";
|
import EntityItem from "./EntityItem";
|
||||||
|
import EntityLiving from "./EntityLiving";
|
||||||
|
import Item from "../items/Item";
|
||||||
|
import ItemStack from "../inventories/ItemStack";
|
||||||
|
import MinecraftServer from "../MinecraftServer";
|
||||||
|
import MPClient from "../MPClient";
|
||||||
|
import PacketCollectItem from "../packets/CollectItem";
|
||||||
|
import PacketEntityEquipment from "../packets/EntityEquipment";
|
||||||
|
import PacketMapChunk from "../packets/MapChunk";
|
||||||
|
import PacketPreChunk from "../packets/PreChunk";
|
||||||
|
import PacketUpdateHealth from "../packets/UpdateHealth";
|
||||||
|
import PlayerInventory from "../inventories/PlayerInventory";
|
||||||
|
import World from "../World";
|
||||||
|
|
||||||
const CHUNK_LOAD_RANGE = 15;
|
const CHUNK_LOAD_RANGE = 15;
|
||||||
|
|
||||||
export class Player extends EntityLiving {
|
export default class Player extends EntityLiving {
|
||||||
public username:string;
|
public username:string;
|
||||||
private server:MinecraftServer;
|
private server:MinecraftServer;
|
||||||
private firstUpdate:boolean;
|
private firstUpdate:boolean;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export enum Animation {
|
enum Animation {
|
||||||
None = 0,
|
None = 0,
|
||||||
SwingArm = 1,
|
SwingArm = 1,
|
||||||
Damage = 2,
|
Damage = 2,
|
||||||
|
@ -7,3 +7,5 @@ export enum Animation {
|
||||||
Crouch = 104,
|
Crouch = 104,
|
||||||
Uncrouch = 105,
|
Uncrouch = 105,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Animation;
|
|
@ -1,4 +1,4 @@
|
||||||
export enum EntityStatus {
|
enum EntityStatus {
|
||||||
Unknown0,
|
Unknown0,
|
||||||
Unknown1,
|
Unknown1,
|
||||||
Hurt,
|
Hurt,
|
||||||
|
@ -6,3 +6,5 @@ export enum EntityStatus {
|
||||||
Unknown4,
|
Unknown4,
|
||||||
Unknown5
|
Unknown5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default EntityStatus;
|
|
@ -1,7 +1,9 @@
|
||||||
export enum MaxUses {
|
enum MaxUses {
|
||||||
GOLD = 32,
|
GOLD = 32,
|
||||||
WOOD = 59,
|
WOOD = 59,
|
||||||
STONE = 131,
|
STONE = 131,
|
||||||
IRON = 250,
|
IRON = 250,
|
||||||
DIAMOND = 1561
|
DIAMOND = 1561
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default MaxUses;
|
|
@ -1,4 +1,4 @@
|
||||||
export enum MetadataFieldType {
|
enum MetadataFieldType {
|
||||||
Byte = 0,
|
Byte = 0,
|
||||||
Short = 1,
|
Short = 1,
|
||||||
Int = 2,
|
Int = 2,
|
||||||
|
@ -7,3 +7,5 @@ export enum MetadataFieldType {
|
||||||
Item = 5,
|
Item = 5,
|
||||||
Vector = 6
|
Vector = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default MetadataFieldType;
|
|
@ -1,5 +1,5 @@
|
||||||
// https://wiki.vg/index.php?title=Protocol&oldid=488
|
// https://wiki.vg/index.php?title=Protocol&oldid=488
|
||||||
export enum Packet {
|
enum Packet {
|
||||||
KeepAlive = 0x00,
|
KeepAlive = 0x00,
|
||||||
LoginRequest = 0x01,
|
LoginRequest = 0x01,
|
||||||
Handshake = 0x02,
|
Handshake = 0x02,
|
||||||
|
@ -50,3 +50,5 @@ export enum Packet {
|
||||||
|
|
||||||
DisconnectKick = 0xff
|
DisconnectKick = 0xff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Packet;
|
|
@ -1,5 +1,7 @@
|
||||||
export enum SaveCompressionType {
|
enum SaveCompressionType {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
DEFLATE = 1,
|
DEFLATE = 1,
|
||||||
XZ = 2
|
XZ = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default SaveCompressionType;
|
|
@ -1,4 +1,4 @@
|
||||||
export enum SoundEffects {
|
enum SoundEffects {
|
||||||
CLICK2 = 1000,
|
CLICK2 = 1000,
|
||||||
CLICK1 = 1001,
|
CLICK1 = 1001,
|
||||||
BOW_FIRE = 1002,
|
BOW_FIRE = 1002,
|
||||||
|
@ -8,3 +8,5 @@ export enum SoundEffects {
|
||||||
SMOKE = 2000,
|
SMOKE = 2000,
|
||||||
BLOCK_BREAK = 2001
|
BLOCK_BREAK = 2001
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default SoundEffects;
|
|
@ -1,5 +1,5 @@
|
||||||
import { Chunk } from "../Chunk";
|
import Chunk from "../Chunk";
|
||||||
|
|
||||||
export interface IGenerator {
|
export default interface IGenerator {
|
||||||
generate: (chunk:Chunk) => void
|
generate: (chunk:Chunk) => void
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
import { Block } from "../blocks/Block";
|
import Block from "../../blocks/Block";
|
||||||
import { Chunk } from "../Chunk";
|
import Chunk from "../../Chunk";
|
||||||
import { IGenerator } from "./IGenerator";
|
import IGenerator from "../IGenerator";
|
||||||
|
|
||||||
export class FlatGenerator implements IGenerator {
|
export default class FlatGenerator implements IGenerator {
|
||||||
public generate(chunk:Chunk) {
|
public generate(chunk:Chunk) {
|
||||||
for (let x = 0; x < 16; x++) {
|
for (let x = 0; x < 16; x++) {
|
||||||
for (let z = 0; z < 16; z++) {
|
for (let z = 0; z < 16; z++) {
|
|
@ -1,12 +1,12 @@
|
||||||
import { Block } from "../blocks/Block";
|
import { Noise2D, makeNoise2D } from "../../../external/OpenSimplex2D";
|
||||||
import { Chunk } from "../Chunk";
|
import { Noise3D, makeNoise3D } from "../../../external/OpenSimplex3D";
|
||||||
import { IGenerator } from "./IGenerator";
|
import Block from "../../blocks/Block";
|
||||||
import { Noise2D, makeNoise2D } from "../../external/OpenSimplex2D";
|
import Chunk from "../../Chunk";
|
||||||
import { Noise3D, makeNoise3D } from "../../external/OpenSimplex3D";
|
import IGenerator from "../IGenerator";
|
||||||
import { QueuedBlockUpdate } from "../queuedUpdateTypes/BlockUpdate";
|
import mulberry32 from "../../mulberry32";
|
||||||
import mulberry32 from "../mulberry32";
|
import QueuedBlockUpdate from "../../queuedUpdateTypes/BlockUpdate";
|
||||||
|
|
||||||
export class HillyGenerator implements IGenerator {
|
export default class HillyGenerator implements IGenerator {
|
||||||
private seed:number;
|
private seed:number;
|
||||||
seedGenerator:() => number;
|
seedGenerator:() => number;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { Block } from "../blocks/Block";
|
import { Noise2D, makeNoise2D } from "../../../external/OpenSimplex2D";
|
||||||
import { Chunk } from "../Chunk";
|
import { Noise3D, makeNoise3D } from "../../../external/OpenSimplex3D";
|
||||||
import { IGenerator } from "./IGenerator";
|
import Block from "../../blocks/Block";
|
||||||
import { Noise2D, makeNoise2D } from "../../external/OpenSimplex2D";
|
import Chunk from "../../Chunk";
|
||||||
import { Noise3D, makeNoise3D } from "../../external/OpenSimplex3D";
|
import IGenerator from "../IGenerator";
|
||||||
import { QueuedBlockUpdate } from "../queuedUpdateTypes/BlockUpdate";
|
import mulberry32 from "../../mulberry32";
|
||||||
import mulberry32 from "../mulberry32";
|
|
||||||
|
|
||||||
export class NetherGenerator implements IGenerator {
|
export default class NetherGenerator implements IGenerator {
|
||||||
private seed:number;
|
private seed:number;
|
||||||
seedGenerator:() => number;
|
seedGenerator:() => number;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
import { makeNoise2D, Noise2D } from "../../external/OpenSimplex2D";
|
import { makeNoise2D, Noise2D } from "../../../external/OpenSimplex2D";
|
||||||
import { makeNoise3D, Noise3D } from "../../external/OpenSimplex3D";
|
import { makeNoise3D, Noise3D } from "../../../external/OpenSimplex3D";
|
||||||
import { Block } from "../blocks/Block";
|
import Block from "../../blocks/Block";
|
||||||
import { Chunk } from "../Chunk";
|
import Chunk from "../../Chunk";
|
||||||
import mulberry32 from "../mulberry32";
|
import IGenerator from "../IGenerator";
|
||||||
import { IGenerator } from "./IGenerator";
|
import mulberry32 from "../../mulberry32";
|
||||||
|
|
||||||
export class NewOverworld implements IGenerator {
|
export default class NewOverworld implements IGenerator {
|
||||||
private seed:number;
|
private seed:number;
|
||||||
seedGenerator:() => number;
|
seedGenerator:() => number;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { IReader, IWriter } from "bufferstuff";
|
import { IReader, IWriter } from "bufferstuff";
|
||||||
import { ItemStack } from "./ItemStack";
|
import ItemStack from "./ItemStack";
|
||||||
|
|
||||||
export default interface IInventory {
|
export default interface IInventory {
|
||||||
fromSave:(reader:IReader) => void,
|
fromSave:(reader:IReader) => void,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Endian, IReader, IWriter, createWriter } from "bufferstuff";
|
import { Endian, IReader, IWriter, createWriter } from "bufferstuff";
|
||||||
import { ItemStack } from "./ItemStack";
|
|
||||||
import IInventory from "./IInventory";
|
import IInventory from "./IInventory";
|
||||||
|
import ItemStack from "./ItemStack";
|
||||||
|
|
||||||
export class Inventory implements IInventory {
|
export default class Inventory implements IInventory {
|
||||||
public itemStacks:Array<ItemStack | null>;
|
public itemStacks:Array<ItemStack | null>;
|
||||||
|
|
||||||
private size:number;
|
private size:number;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { IReader, IWriter } from "bufferstuff";
|
import { IReader, IWriter } from "bufferstuff";
|
||||||
import { Block } from "../blocks/Block";
|
import Block from "../blocks/Block";
|
||||||
import { IEntity } from "../entities/IEntity";
|
import IEntity from "../entities/IEntity";
|
||||||
import { Player } from "../entities/Player";
|
import Item from "../items/Item";
|
||||||
import { Item } from "../items/Item";
|
|
||||||
|
|
||||||
export class ItemStack {
|
export default class ItemStack {
|
||||||
private static ITEMSTACK_ID_ADDER = 0;
|
private static ITEMSTACK_ID_ADDER = 0;
|
||||||
private readonly itemStackId:number;
|
private readonly itemStackId:number;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Player } from "../entities/Player";
|
import Inventory from "./Inventory";
|
||||||
import { PacketSetSlot } from "../packets/SetSlot";
|
import ItemStack from "./ItemStack";
|
||||||
import { PacketWindowItems } from "../packets/WindowItems";
|
import PacketSetSlot from "../packets/SetSlot";
|
||||||
import { Inventory } from "./Inventory";
|
import PacketWindowItems from "../packets/WindowItems";
|
||||||
import { ItemStack } from "./ItemStack";
|
import Player from "../entities/Player";
|
||||||
|
|
||||||
export default class PlayerInventory extends Inventory {
|
export default class PlayerInventory extends Inventory {
|
||||||
private player:Player;
|
private player:Player;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { MaxUses } from "../enums/MaxUses";
|
import MaxUses from "../enums/MaxUses";
|
||||||
|
|
||||||
export class Item {
|
export default class Item {
|
||||||
public static items:Array<Item> = new Array<Item>();
|
public static items:Array<Item> = new Array<Item>();
|
||||||
|
|
||||||
public maxStackSize:number;
|
public maxStackSize:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketAnimation implements IPacket {
|
export default class PacketAnimation implements IPacket {
|
||||||
public packetId = Packet.Animation;
|
public packetId = Packet.Animation;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public animation:number;
|
public animation:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketBlockChange implements IPacket {
|
export default class PacketBlockChange implements IPacket {
|
||||||
public packetId = Packet.BlockChange;
|
public packetId = Packet.BlockChange;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketChat implements IPacket {
|
export default class PacketChat implements IPacket {
|
||||||
public packetId = Packet.Chat;
|
public packetId = Packet.Chat;
|
||||||
public message:string;
|
public message:string;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketCollectItem implements IPacket {
|
export default class PacketCollectItem implements IPacket {
|
||||||
public packetId = Packet.CollectItem;
|
public packetId = Packet.CollectItem;
|
||||||
public collectedEID:number;
|
public collectedEID:number;
|
||||||
public collectorEID:number;
|
public collectorEID:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketDestroyEntity implements IPacket {
|
export default class PacketDestroyEntity implements IPacket {
|
||||||
public packetId = Packet.DestroyEntity;
|
public packetId = Packet.DestroyEntity;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketDisconnectKick implements IPacket {
|
export default class PacketDisconnectKick implements IPacket {
|
||||||
public packetId = Packet.DisconnectKick;
|
public packetId = Packet.DisconnectKick;
|
||||||
public reason:string;
|
public reason:string;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntity implements IPacket {
|
export default class PacketEntity implements IPacket {
|
||||||
public packetId = Packet.Entity;
|
public packetId = Packet.Entity;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityAction implements IPacket {
|
export default class PacketEntityAction implements IPacket {
|
||||||
public packetId = Packet.EntityAction;
|
public packetId = Packet.EntityAction;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public action:number;
|
public action:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityEquipment implements IPacket {
|
export default class PacketEntityEquipment implements IPacket {
|
||||||
public packetId = Packet.EntityEquipment;
|
public packetId = Packet.EntityEquipment;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public slot:number;
|
public slot:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityLook implements IPacket {
|
export default class PacketEntityLook implements IPacket {
|
||||||
public packetId = Packet.EntityLook;
|
public packetId = Packet.EntityLook;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public yaw:number;
|
public yaw:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityLookRelativeMove implements IPacket {
|
export default class PacketEntityLookRelativeMove implements IPacket {
|
||||||
public packetId = Packet.EntityLookRelativeMove;
|
public packetId = Packet.EntityLookRelativeMove;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public dX:number;
|
public dX:number;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
const EMPTY_BUFFER = Buffer.alloc(0);
|
const EMPTY_BUFFER = Buffer.alloc(0);
|
||||||
|
|
||||||
export class PacketEntityMetadata implements IPacket {
|
export default class PacketEntityMetadata implements IPacket {
|
||||||
public packetId = Packet.EntityMetadata;
|
public packetId = Packet.EntityMetadata;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public metadata:Buffer;
|
public metadata:Buffer;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityRelativeMove implements IPacket {
|
export default class PacketEntityRelativeMove implements IPacket {
|
||||||
public packetId = Packet.EntityRelativeMove;
|
public packetId = Packet.EntityRelativeMove;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public dX:number;
|
public dX:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityStatus implements IPacket {
|
export default class PacketEntityStatus implements IPacket {
|
||||||
public packetId = Packet.EntityStatus;
|
public packetId = Packet.EntityStatus;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public status:number;
|
public status:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketEntityTeleport implements IPacket {
|
export default class PacketEntityTeleport implements IPacket {
|
||||||
public packetId = Packet.EntityTeleport;
|
public packetId = Packet.EntityTeleport;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public x:number;
|
public x:number;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
const MOTION_MAX = 3.9;
|
const MOTION_MAX = 3.9;
|
||||||
function maxMotion(value:number) {
|
function maxMotion(value:number) {
|
||||||
|
@ -13,7 +13,7 @@ function maxMotion(value:number) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PacketEntityVelocity implements IPacket {
|
export default class PacketEntityVelocity implements IPacket {
|
||||||
public packetId = Packet.EntityVelocity;
|
public packetId = Packet.EntityVelocity;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public x:number;
|
public x:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketHandshake implements IPacket {
|
export default class PacketHandshake implements IPacket {
|
||||||
public packetId:Packet = Packet.Handshake;
|
public packetId:Packet = Packet.Handshake;
|
||||||
private username:string;
|
private username:string;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketHoldingChange implements IPacket {
|
export default class PacketHoldingChange implements IPacket {
|
||||||
public packetId = Packet.HoldingChange;
|
public packetId = Packet.HoldingChange;
|
||||||
public slotId:number;
|
public slotId:number;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { IReader } from "bufferstuff";
|
import { IReader } from "bufferstuff";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export interface IPacket {
|
export default interface IPacket {
|
||||||
packetId: Packet,
|
packetId: Packet,
|
||||||
readData: (reader:IReader) => IPacket,
|
readData: (reader:IReader) => IPacket,
|
||||||
writeData: () => Buffer|Promise<Buffer>
|
writeData: () => Buffer|Promise<Buffer>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketKeepAlive implements IPacket {
|
export default class PacketKeepAlive implements IPacket {
|
||||||
public packetId = Packet.KeepAlive;
|
public packetId = Packet.KeepAlive;
|
||||||
private static readonly KeepAliveBuffer:Buffer = createWriter(Endian.BE, 1).writeByte(Packet.KeepAlive).toBuffer();
|
private static readonly KeepAliveBuffer:Buffer = createWriter(Endian.BE, 1).writeByte(Packet.KeepAlive).toBuffer();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketLoginRequest implements IPacket {
|
export default class PacketLoginRequest implements IPacket {
|
||||||
public packetId = Packet.LoginRequest;
|
public packetId = Packet.LoginRequest;
|
||||||
public protocolVersion:number;
|
public protocolVersion:number;
|
||||||
public username:string;
|
public username:string;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { Chunk } from "../Chunk";
|
|
||||||
import { deflate } from "zlib";
|
import { deflate } from "zlib";
|
||||||
import { IPacket } from "./IPacket";
|
import Chunk from "../Chunk";
|
||||||
import { Packet } from "../enums/Packet";
|
import IPacket from "./IPacket";
|
||||||
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketMapChunk implements IPacket {
|
export default class PacketMapChunk implements IPacket {
|
||||||
public packetId = Packet.MapChunk;
|
public packetId = Packet.MapChunk;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketNamedEntitySpawn implements IPacket {
|
export default class PacketNamedEntitySpawn implements IPacket {
|
||||||
public packetId = Packet.NamedEntitySpawn;
|
public packetId = Packet.NamedEntitySpawn;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public playerName:string;
|
public playerName:string;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPickupSpawn implements IPacket {
|
export default class PacketPickupSpawn implements IPacket {
|
||||||
public packetId = Packet.PickupSpawn;
|
public packetId = Packet.PickupSpawn;
|
||||||
public entityId:number;
|
public entityId:number;
|
||||||
public item:number;
|
public item:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPlayer implements IPacket {
|
export default class PacketPlayer implements IPacket {
|
||||||
public packetId = Packet.Player;
|
public packetId = Packet.Player;
|
||||||
public onGround:boolean;
|
public onGround:boolean;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPlayerBlockPlacement implements IPacket {
|
export default class PacketPlayerBlockPlacement implements IPacket {
|
||||||
public packetId = Packet.PlayerBlockPlacement;
|
public packetId = Packet.PlayerBlockPlacement;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPlayerDigging implements IPacket {
|
export default class PacketPlayerDigging implements IPacket {
|
||||||
public packetId = Packet.PlayerDigging;
|
public packetId = Packet.PlayerDigging;
|
||||||
public status:number;
|
public status:number;
|
||||||
public x:number;
|
public x:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPlayerLook implements IPacket {
|
export default class PacketPlayerLook implements IPacket {
|
||||||
public packetId = Packet.Player;
|
public packetId = Packet.Player;
|
||||||
public yaw:number;
|
public yaw:number;
|
||||||
public pitch:number;
|
public pitch:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPlayerPosition implements IPacket {
|
export default class PacketPlayerPosition implements IPacket {
|
||||||
public packetId = Packet.PlayerPosition;
|
public packetId = Packet.PlayerPosition;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPlayerPositionLook implements IPacket {
|
export default class PacketPlayerPositionLook implements IPacket {
|
||||||
public packetId = Packet.PlayerPosition;
|
public packetId = Packet.PlayerPosition;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketPreChunk implements IPacket {
|
export default class PacketPreChunk implements IPacket {
|
||||||
public packetId = Packet.PreChunk;
|
public packetId = Packet.PreChunk;
|
||||||
public x:number;
|
public x:number;
|
||||||
public z:number;
|
public z:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketRespawn implements IPacket {
|
export default class PacketRespawn implements IPacket {
|
||||||
public packetId = Packet.Respawn;
|
public packetId = Packet.Respawn;
|
||||||
public dimension:number;
|
public dimension:number;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketSetSlot implements IPacket {
|
export default class PacketSetSlot implements IPacket {
|
||||||
public packetId = Packet.SetSlot;
|
public packetId = Packet.SetSlot;
|
||||||
public windowId:number;
|
public windowId:number;
|
||||||
public slot:number;
|
public slot:number;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
import { SoundEffects } from "../enums/SoundEffects";
|
import SoundEffects from "../enums/SoundEffects";
|
||||||
|
|
||||||
export class PacketSoundEffect implements IPacket {
|
export default class PacketSoundEffect implements IPacket {
|
||||||
public packetId = Packet.SoundEffect;
|
public packetId = Packet.SoundEffect;
|
||||||
public effectId:SoundEffects;
|
public effectId:SoundEffects;
|
||||||
public x:number;
|
public x:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketSpawnPosition implements IPacket {
|
export default class PacketSpawnPosition implements IPacket {
|
||||||
public packetId = Packet.SpawnPosition;
|
public packetId = Packet.SpawnPosition;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketTimeUpdate implements IPacket {
|
export default class PacketTimeUpdate implements IPacket {
|
||||||
public packetId = Packet.TimeUpdate;
|
public packetId = Packet.TimeUpdate;
|
||||||
public time:bigint;
|
public time:bigint;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketUpdateHealth implements IPacket {
|
export default class PacketUpdateHealth implements IPacket {
|
||||||
public packetId = Packet.UpdateHealth;
|
public packetId = Packet.UpdateHealth;
|
||||||
public health:number;
|
public health:number;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketUseEntity implements IPacket {
|
export default class PacketUseEntity implements IPacket {
|
||||||
public packetId = Packet.UseEntity;
|
public packetId = Packet.UseEntity;
|
||||||
public userId:number;
|
public userId:number;
|
||||||
public targetId:number;
|
public targetId:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketWindowClick implements IPacket {
|
export default class PacketWindowClick implements IPacket {
|
||||||
public packetId = Packet.WindowClick;
|
public packetId = Packet.WindowClick;
|
||||||
public windowId:number;
|
public windowId:number;
|
||||||
public slot:number;
|
public slot:number;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createWriter, IReader, Endian } from "bufferstuff";
|
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||||
import { IPacket } from "./IPacket";
|
import IPacket from "./IPacket";
|
||||||
import { Packet } from "../enums/Packet";
|
import Packet from "../enums/Packet";
|
||||||
|
|
||||||
export class PacketWindowItems implements IPacket {
|
export default class PacketWindowItems implements IPacket {
|
||||||
public packetId = Packet.WindowItems;
|
public packetId = Packet.WindowItems;
|
||||||
public windowId:number;
|
public windowId:number;
|
||||||
public count:number;
|
public count:number;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { IQueuedUpdate } from "./IQueuedUpdate";
|
import IQueuedUpdate from "./IQueuedUpdate";
|
||||||
|
|
||||||
export class QueuedBlockUpdate implements IQueuedUpdate {
|
export default class QueuedBlockUpdate implements IQueuedUpdate {
|
||||||
public coordPair:number;
|
public coordPair:number;
|
||||||
public x:number;
|
public x:number;
|
||||||
public y:number;
|
public y:number;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export interface IQueuedUpdate {}
|
export default interface IQueuedUpdate {}
|
|
@ -57,7 +57,7 @@ for (const line of splitLines) {
|
||||||
}
|
}
|
||||||
// Fix up classes, interfaces and such.
|
// Fix up classes, interfaces and such.
|
||||||
//resultLines.push(line);
|
//resultLines.push(line);
|
||||||
resultLines.push(line.replace("export default function", "function").replace("export class", "class").replace("export interface", "interface").replace("export enum", "enum").replace("export type", "type"));
|
resultLines.push(line.replace("export default function", "function").replace("export class", "class").replace("export default class", "class").replace("export interface", "interface").replace("export enum", "enum").replace("export type", "type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFileSync("./combined.ts", resultLines.join("\n"));
|
writeFileSync("./combined.ts", resultLines.join("\n"));
|
||||||
|
|
Loading…
Reference in a new issue