From 78c894a94d13ab497bf35a05b6593dc8966308b8 Mon Sep 17 00:00:00 2001 From: Holly Date: Sat, 26 Oct 2024 14:24:38 +0100 Subject: [PATCH] convert whole project to use default exports --- config.ts | 4 +- index.ts | 9 ++-- nibbleArray.ts | 2 +- server/Chunk.ts | 12 ++--- server/EntityMetadata.ts | 2 +- server/MPClient.ts | 50 +++++++++--------- server/MetadataWriter.ts | 4 +- server/MinecraftServer.ts | 51 ++++++++++--------- server/Rotation.ts | 4 +- server/TrackedProperty.ts | 2 +- server/Vec2.ts | 2 +- server/World.ts | 32 ++++++------ server/WorldSaveManager.ts | 16 +++--- server/blocks/Block.ts | 22 ++++---- server/blocks/BlockBehaviorSapling.ts | 6 +-- server/blocks/BlockBehaviorSugarcane.ts | 8 +-- server/blocks/BlockBehaviour.ts | 8 +-- server/blocks/BlockBehaviourClay.ts | 6 +-- server/blocks/BlockBehaviourFlower.ts | 8 +-- server/blocks/BlockBehaviourGrass.ts | 6 +-- server/blocks/BlockBehaviourOre.ts | 4 +- server/blocks/BlockBehaviourRedstoneOre.ts | 4 +- server/blocks/BlockBehaviourStone.ts | 6 +-- server/blocks/BlockBehaviourTallGrass.ts | 8 +-- server/blocks/IBlockBehaviour.ts | 6 +-- server/entities/Entity.ts | 42 +++++++-------- server/entities/EntityItem.ts | 9 ++-- server/entities/EntityLiving.ts | 14 ++--- server/entities/IEntity.ts | 2 +- server/entities/Player.ts | 36 +++++++------ server/enums/Animation.ts | 6 ++- server/enums/EntityStatus.ts | 6 ++- server/enums/MaxUses.ts | 6 ++- server/enums/MetadataFieldType.ts | 6 ++- server/enums/Packet.ts | 6 ++- server/enums/SaveCompressionType.ts | 6 ++- server/enums/SoundEffects.ts | 6 ++- server/generators/IGenerator.ts | 4 +- server/generators/{ => terrain}/Flat.ts | 8 +-- server/generators/{ => terrain}/Hilly.ts | 16 +++--- server/generators/{ => terrain}/Nether.ts | 15 +++--- .../generators/{ => terrain}/NewOverworld.ts | 14 ++--- server/inventories/IInventory.ts | 2 +- server/inventories/Inventory.ts | 4 +- server/inventories/ItemStack.ts | 9 ++-- server/inventories/PlayerInventory.ts | 10 ++-- server/items/Item.ts | 4 +- server/packets/Animation.ts | 6 +-- server/packets/BlockChange.ts | 6 +-- server/packets/Chat.ts | 6 +-- server/packets/CollectItem.ts | 6 +-- server/packets/DestroyEntity.ts | 6 +-- server/packets/DisconnectKick.ts | 6 +-- server/packets/Entity.ts | 6 +-- server/packets/EntityAction.ts | 6 +-- server/packets/EntityEquipment.ts | 6 +-- server/packets/EntityLook.ts | 6 +-- server/packets/EntityLookRelativeMove.ts | 6 +-- server/packets/EntityMetadata.ts | 6 +-- server/packets/EntityRelativeMove.ts | 6 +-- server/packets/EntityStatus.ts | 6 +-- server/packets/EntityTeleport.ts | 6 +-- server/packets/EntityVelocity.ts | 6 +-- server/packets/Handshake.ts | 6 +-- server/packets/HoldingChange.ts | 6 +-- server/packets/IPacket.ts | 4 +- server/packets/KeepAlive.ts | 6 +-- server/packets/LoginRequest.ts | 6 +-- server/packets/MapChunk.ts | 8 +-- server/packets/NamedEntitySpawn.ts | 6 +-- server/packets/PickupSpawn.ts | 6 +-- server/packets/Player.ts | 6 +-- server/packets/PlayerBlockPlacement.ts | 6 +-- server/packets/PlayerDigging.ts | 6 +-- server/packets/PlayerLook.ts | 6 +-- server/packets/PlayerPosition.ts | 6 +-- server/packets/PlayerPositionLook.ts | 6 +-- server/packets/PreChunk.ts | 6 +-- server/packets/Respawn.ts | 6 +-- server/packets/SetSlot.ts | 6 +-- server/packets/SoundEffect.ts | 8 +-- server/packets/SpawnPosition.ts | 6 +-- server/packets/TimeUpdate.ts | 6 +-- server/packets/UpdateHealth.ts | 6 +-- server/packets/UseEntity.ts | 6 +-- server/packets/WindowClick.ts | 6 +-- server/packets/WindowItems.ts | 6 +-- server/queuedUpdateTypes/BlockUpdate.ts | 4 +- server/queuedUpdateTypes/IQueuedUpdate.ts | 2 +- tooling/fileSmasher.ts | 2 +- 90 files changed, 386 insertions(+), 377 deletions(-) rename server/generators/{ => terrain}/Flat.ts (73%) rename server/generators/{ => terrain}/Hilly.ts (94%) rename server/generators/{ => terrain}/Nether.ts (81%) rename server/generators/{ => terrain}/NewOverworld.ts (85%) diff --git a/config.ts b/config.ts index de7d7f9..b7457fe 100644 --- a/config.ts +++ b/config.ts @@ -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, maxPlayers: number, seed: number|string, diff --git a/index.ts b/index.ts index bb294d7..6a69c9b 100644 --- a/index.ts +++ b/index.ts @@ -1,8 +1,9 @@ -import { Config } from "./config"; -import { Console } from "hsconsole"; import { readFileSync } from "fs"; -import { MinecraftServer } from "./server/MinecraftServer"; -import { SaveCompressionType } from "./server/enums/SaveCompressionType"; +import { Console } from "hsconsole"; +import Config from "./config"; +import MinecraftServer from "./server/MinecraftServer"; +import SaveCompressionType from "./server/enums/SaveCompressionType"; + const tempConfig = JSON.parse(readFileSync("./config.json").toString()); tempConfig.saveCompression = SaveCompressionType[tempConfig.saveCompression]; const config:Config = tempConfig as Config; diff --git a/nibbleArray.ts b/nibbleArray.ts index 5500cc9..ee519e9 100644 --- a/nibbleArray.ts +++ b/nibbleArray.ts @@ -1,4 +1,4 @@ -export class NibbleArray { +export default class NibbleArray { private array:Uint8Array; public constructor(size:number|ArrayBuffer|Uint8Array) { diff --git a/server/Chunk.ts b/server/Chunk.ts index b954fbd..3247034 100644 --- a/server/Chunk.ts +++ b/server/Chunk.ts @@ -1,11 +1,11 @@ +import Block from "./blocks/Block"; import FunkyArray from "funky-array"; -import { NibbleArray } from "../nibbleArray"; -import { Block } from "./blocks/Block"; -import { Player } from "./entities/Player"; -import { QueuedBlockUpdate } from "./queuedUpdateTypes/BlockUpdate"; -import { World } from "./World"; +import NibbleArray from "../nibbleArray"; +import Player from "./entities/Player"; +import QueuedBlockUpdate from "./queuedUpdateTypes/BlockUpdate"; +import World from "./World"; -export class Chunk { +export default class Chunk { private readonly MAX_HEIGHT:number = 128; private readonly FULLBRIGHT = false; public readonly world:World; diff --git a/server/EntityMetadata.ts b/server/EntityMetadata.ts index 921b36f..e002d20 100644 --- a/server/EntityMetadata.ts +++ b/server/EntityMetadata.ts @@ -1,5 +1,5 @@ import { MetadataEntry, MetadataWriter } from "./MetadataWriter"; -import { MetadataFieldType } from "./enums/MetadataFieldType"; +import MetadataFieldType from "./enums/MetadataFieldType"; export default class EntityMetadata { public onFire:boolean = false; diff --git a/server/MPClient.ts b/server/MPClient.ts index bf361a1..b3d6ebd 100644 --- a/server/MPClient.ts +++ b/server/MPClient.ts @@ -1,33 +1,33 @@ -import { Console } from "hsconsole"; import { IReader } from "bufferstuff"; -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 { Player } from "./entities/Player"; +import { Console } from "hsconsole"; 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 { PacketSoundEffect } from "./packets/SoundEffect"; -import { SoundEffects } from "./enums/SoundEffects"; -import { PacketUseEntity } from "./packets/UseEntity"; -import { EntityLiving } from "./entities/EntityLiving"; +import Block from "./blocks/Block"; +import EntityLiving from "./entities/EntityLiving"; +import EntityItem from "./entities/EntityItem"; +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 SoundEffects from "./enums/SoundEffects"; +import Vec3 from "./Vec3"; -export class MPClient { +export default class MPClient { private readonly mcServer:MinecraftServer; private readonly socket:Socket; public entity:Player; diff --git a/server/MetadataWriter.ts b/server/MetadataWriter.ts index 3ba2836..6409889 100644 --- a/server/MetadataWriter.ts +++ b/server/MetadataWriter.ts @@ -1,8 +1,8 @@ import { createWriter, Endian } from "bufferstuff"; 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 { ItemStack } from "./inventories/ItemStack"; export class MetadataEntry { public type:MetadataFieldType; diff --git a/server/MinecraftServer.ts b/server/MinecraftServer.ts index 4e94882..b2620e9 100644 --- a/server/MinecraftServer.ts +++ b/server/MinecraftServer.ts @@ -1,29 +1,28 @@ -import { Config } from "../config"; -import { Console } from "hsconsole"; 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 { 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 chunkTo = 15; @@ -34,7 +33,7 @@ function getRandomSeed() { return getRandomValues(arr)[0]; } -export class MinecraftServer { +export default class MinecraftServer { private static readonly PROTOCOL_VERSION = 14; private static readonly TICK_RATE = 20; private static readonly TICK_RATE_MS = 1000 / MinecraftServer.TICK_RATE; @@ -83,6 +82,7 @@ export class MinecraftServer { // Save chunks Console.printInfo("Saving worlds..."); // There's a race condition here. oops. + const keepRunningInterval = setInterval(() => {}, 1000); let savedWorldCount = 0; let savedChunkCount = 0; await this.worlds.forEach(async (world) => { @@ -101,6 +101,7 @@ export class MinecraftServer { // hsconsole is gone now so we have to use built in. console.log("Goodbye"); + clearInterval(keepRunningInterval); }); if (this.config.saveCompression === SaveCompressionType.NONE) { diff --git a/server/Rotation.ts b/server/Rotation.ts index 63f4aff..c6fc33e 100644 --- a/server/Rotation.ts +++ b/server/Rotation.ts @@ -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() { return this.x; } diff --git a/server/TrackedProperty.ts b/server/TrackedProperty.ts index 12b596b..8f2adc2 100644 --- a/server/TrackedProperty.ts +++ b/server/TrackedProperty.ts @@ -1,4 +1,4 @@ -export class TrackedProperty { +export default class TrackedProperty { private trackedValue?:T; private updateCallback?:(value:T) => void; diff --git a/server/Vec2.ts b/server/Vec2.ts index 812a60f..6d5195a 100644 --- a/server/Vec2.ts +++ b/server/Vec2.ts @@ -1,4 +1,4 @@ -export class Vec2 { +export default class Vec2 { public x:number; public y:number; diff --git a/server/World.ts b/server/World.ts index 66681a7..204fe31 100644 --- a/server/World.ts +++ b/server/World.ts @@ -1,23 +1,21 @@ 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 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 WorldSaveManager from "./WorldSaveManager"; -export class World { +export default class World { public static ENTITY_MAX_SEND_DISTANCE = 50; private static READ_CHUNKS_FROM_DISK = true; @@ -198,7 +196,7 @@ export class World { chunk.setBlockWithMetadata(blockId, metadata, x & 0xf, y, z & 0xf); 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 chunk.playersInChunk.forEach(player => { player.mpClient?.send(blockUpdatePacket); diff --git a/server/WorldSaveManager.ts b/server/WorldSaveManager.ts index 40467bc..633559a 100644 --- a/server/WorldSaveManager.ts +++ b/server/WorldSaveManager.ts @@ -1,12 +1,12 @@ -import { readFileSync, readFile, writeFile, existsSync, mkdirSync, writeFileSync, readdirSync, renameSync } from "fs"; import { createWriter, createReader, Endian, IWriter, IReader } from "bufferstuff"; -import { Config } from "../config"; -import { Chunk } from "./Chunk"; -import { SaveCompressionType } from "./enums/SaveCompressionType"; -import { deflate, inflate } from "zlib"; -import { World } from "./World"; -import FunkyArray from "funky-array"; +import { readFileSync, readFile, writeFile, existsSync, mkdirSync, writeFileSync, readdirSync, renameSync } from "fs"; 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 { Chunk = 0xFC, @@ -14,7 +14,7 @@ enum FileMagic { Player = 0xFE } -export class WorldSaveManager { +export default class WorldSaveManager { private readonly worldFolderPath; private readonly globalDataPath; private readonly worldPlayerDataFolderPath; diff --git a/server/blocks/Block.ts b/server/blocks/Block.ts index bbd73f5..3376861 100644 --- a/server/blocks/Block.ts +++ b/server/blocks/Block.ts @@ -1,16 +1,16 @@ import AABB from "../AABB"; -import { World } from "../World"; -import { BlockBehaviourSapling } from "./BlockBehaviorSapling"; -import { BlockBehaviourSugarcane } from "./BlockBehaviorSugarcane"; -import { BlockBehaviour } from "./BlockBehaviour"; -import { BlockBehaviourClay } from "./BlockBehaviourClay"; -import { BlockBehaviourFlower } from "./BlockBehaviourFlower"; -import { BlockBehaviourGrass } from "./BlockBehaviourGrass"; +import BlockBehaviour from "./BlockBehaviour"; +import BlockBehaviourSapling from "./BlockBehaviorSapling"; +import BlockBehaviourSugarcane from "./BlockBehaviorSugarcane"; +import BlockBehaviourClay from "./BlockBehaviourClay"; +import BlockBehaviourFlower from "./BlockBehaviourFlower"; +import BlockBehaviourGrass from "./BlockBehaviourGrass"; import BlockBehaviourOre from "./BlockBehaviourOre"; import BlockBehaviourRedstoneOre from "./BlockBehaviourRedstoneOre"; -import { BlockBehaviourStone } from "./BlockBehaviourStone"; -import { BlockBehaviourTallGrass } from "./BlockBehaviourTallGrass"; -import { IBlockBehaviour } from "./IBlockBehaviour"; +import BlockBehaviourStone from "./BlockBehaviourStone"; +import BlockBehaviourTallGrass from "./BlockBehaviourTallGrass"; +import IBlockBehaviour from "./IBlockBehaviour"; +import World from "../World"; abstract class Behaviour { public static base = new BlockBehaviour(); @@ -29,7 +29,7 @@ abstract class Behaviour { public static sugarcane = new BlockBehaviourSugarcane(); } -export class Block { +export default class Block { public readonly blockId:number; public static readonly blocks:Array = new Array(); diff --git a/server/blocks/BlockBehaviorSapling.ts b/server/blocks/BlockBehaviorSapling.ts index 289c6d0..f18ed65 100644 --- a/server/blocks/BlockBehaviorSapling.ts +++ b/server/blocks/BlockBehaviorSapling.ts @@ -1,8 +1,8 @@ +import BlockBehaviour from "./BlockBehaviour"; import Random from "../Random"; -import { World } from "../World"; -import { BlockBehaviour } from "./BlockBehaviour"; +import World from "../World"; -export class BlockBehaviourSapling extends BlockBehaviour { +export default class BlockBehaviourSapling extends BlockBehaviour { public randomTick(world:World, x:number, y:number, z:number, random:Random) { if (world.getBlockLight(x, y + 1, z) >= 9 && random.nextInt(30) === 0) { const blockMetadata = world.getBlockMetadata(x, y, z); diff --git a/server/blocks/BlockBehaviorSugarcane.ts b/server/blocks/BlockBehaviorSugarcane.ts index 2f768c7..cc08ee8 100644 --- a/server/blocks/BlockBehaviorSugarcane.ts +++ b/server/blocks/BlockBehaviorSugarcane.ts @@ -1,9 +1,9 @@ import AABB from "../AABB"; -import { World } from "../World"; -import { Block } from "./Block"; -import { BlockBehaviour } from "./BlockBehaviour"; +import Block from "./Block"; +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) { const block = world.getBlockId(x, y - 1, z); if (block === 0 || block !== Block.sugarcane.blockId) { diff --git a/server/blocks/BlockBehaviour.ts b/server/blocks/BlockBehaviour.ts index 70a8606..99307c4 100644 --- a/server/blocks/BlockBehaviour.ts +++ b/server/blocks/BlockBehaviour.ts @@ -1,10 +1,10 @@ import AABB from "../AABB"; +import Block from "./Block"; +import IBlockBehaviour from "./IBlockBehaviour"; import Random from "../Random"; -import { World } from "../World"; -import { Block } from "./Block"; -import { IBlockBehaviour } from "./IBlockBehaviour"; +import World from "../World"; -export class BlockBehaviour implements IBlockBehaviour { +export default class BlockBehaviour implements IBlockBehaviour { public block!:Block; public neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number) {} diff --git a/server/blocks/BlockBehaviourClay.ts b/server/blocks/BlockBehaviourClay.ts index 5466552..192c7a0 100644 --- a/server/blocks/BlockBehaviourClay.ts +++ b/server/blocks/BlockBehaviourClay.ts @@ -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) { return Item.clay.shiftedItemID; } diff --git a/server/blocks/BlockBehaviourFlower.ts b/server/blocks/BlockBehaviourFlower.ts index 8418405..15f000e 100644 --- a/server/blocks/BlockBehaviourFlower.ts +++ b/server/blocks/BlockBehaviourFlower.ts @@ -1,9 +1,9 @@ import AABB from "../AABB"; -import { World } from "../World"; -import { Block } from "./Block"; -import { BlockBehaviour } from "./BlockBehaviour"; +import Block from "./Block"; +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) { const block = world.getBlockId(x, y - 1, z); if (block !== Block.grass.blockId && block !== Block.dirt.blockId) { diff --git a/server/blocks/BlockBehaviourGrass.ts b/server/blocks/BlockBehaviourGrass.ts index 39504df..99c460c 100644 --- a/server/blocks/BlockBehaviourGrass.ts +++ b/server/blocks/BlockBehaviourGrass.ts @@ -1,7 +1,7 @@ -import { Block } from "./Block"; -import { BlockBehaviour } from "./BlockBehaviour"; +import Block from "./Block"; +import BlockBehaviour from "./BlockBehaviour"; -export class BlockBehaviourGrass extends BlockBehaviour { +export default class BlockBehaviourGrass extends BlockBehaviour { public droppedItem(blockId:number) { return Block.dirt.blockId; } diff --git a/server/blocks/BlockBehaviourOre.ts b/server/blocks/BlockBehaviourOre.ts index fea40a9..a930829 100644 --- a/server/blocks/BlockBehaviourOre.ts +++ b/server/blocks/BlockBehaviourOre.ts @@ -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 { public droppedItem(blockId:number) { diff --git a/server/blocks/BlockBehaviourRedstoneOre.ts b/server/blocks/BlockBehaviourRedstoneOre.ts index a369bd7..f6e3fed 100644 --- a/server/blocks/BlockBehaviourRedstoneOre.ts +++ b/server/blocks/BlockBehaviourRedstoneOre.ts @@ -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 { public droppedItem(blockId:number) { diff --git a/server/blocks/BlockBehaviourStone.ts b/server/blocks/BlockBehaviourStone.ts index fd1e789..dbe7b78 100644 --- a/server/blocks/BlockBehaviourStone.ts +++ b/server/blocks/BlockBehaviourStone.ts @@ -1,7 +1,7 @@ -import { Block } from "./Block"; -import { BlockBehaviour } from "./BlockBehaviour"; +import Block from "./Block"; +import BlockBehaviour from "./BlockBehaviour"; -export class BlockBehaviourStone extends BlockBehaviour { +export default class BlockBehaviourStone extends BlockBehaviour { public droppedItem(blockId:number) { return Block.cobblestone.blockId; } diff --git a/server/blocks/BlockBehaviourTallGrass.ts b/server/blocks/BlockBehaviourTallGrass.ts index 4c0d6c5..6f01932 100644 --- a/server/blocks/BlockBehaviourTallGrass.ts +++ b/server/blocks/BlockBehaviourTallGrass.ts @@ -1,9 +1,9 @@ import AABB from "../AABB"; -import { World } from "../World"; -import { Block } from "./Block"; -import { BlockBehaviour } from "./BlockBehaviour"; +import Block from "./Block"; +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) { const block = world.getBlockId(x, y - 1, z); if (block !== Block.grass.blockId && block !== Block.dirt.blockId) { diff --git a/server/blocks/IBlockBehaviour.ts b/server/blocks/IBlockBehaviour.ts index 63ed61f..56735fb 100644 --- a/server/blocks/IBlockBehaviour.ts +++ b/server/blocks/IBlockBehaviour.ts @@ -1,9 +1,9 @@ import AABB from "../AABB"; +import Block from "./Block"; import Random from "../Random"; -import { World } from "../World"; -import { Block } from "./Block"; +import World from "../World"; -export interface IBlockBehaviour { +export default interface IBlockBehaviour { block:Block, neighborBlockChange(world:World, x:number, y:number, z:number, blockId:number): void, diff --git a/server/entities/Entity.ts b/server/entities/Entity.ts index 842fe14..a7cd0f9 100644 --- a/server/entities/Entity.ts +++ b/server/entities/Entity.ts @@ -1,23 +1,23 @@ -import { Endian, IReader, IWriter, createWriter } from "bufferstuff"; -import AABB from "../AABB"; -import { Chunk } from "../Chunk"; +import { IReader, IWriter } from "bufferstuff"; import { MetadataEntry, MetadataWriter } from "../MetadataWriter"; -import { Rotation } from "../Rotation"; -import { Vec2 } from "../Vec2"; +import AABB from "../AABB"; +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 { 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"; +import World from "../World"; -export class Entity implements IEntity { +export default class Entity implements IEntity { public static nextEntityId:number = 0; public entityId:number; @@ -193,11 +193,11 @@ export class Entity implements IEntity { private sendPositionUpdate() { 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! - // There is definitely a better way to do this. + const yaw = this.rotation.yaw / 256 * 180; + const pitch = this.rotation.pitch / 256 * 180; 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 - this.constrainRot(Math.floor((this.rotation.pitch % 360 * 256) / 360)) // Pitch + Math.floor(yaw - Math.floor((yaw + 128) / 256) * 256), + Math.floor(pitch - Math.floor((pitch + 128) / 256) * 256) ); const diffX = this.absPosition.x - this.lastAbsPosition.x; const diffY = this.absPosition.y - this.lastAbsPosition.y; diff --git a/server/entities/EntityItem.ts b/server/entities/EntityItem.ts index 7e306ef..7a973cc 100644 --- a/server/entities/EntityItem.ts +++ b/server/entities/EntityItem.ts @@ -1,9 +1,8 @@ -import { World } from "../World"; -import { ItemStack } from "../inventories/ItemStack"; -import { Entity } from "./Entity"; -import { Player } from "./Player"; +import Entity from "./Entity"; +import ItemStack from "../inventories/ItemStack"; +import World from "../World"; -export class EntityItem extends Entity { +export default class EntityItem extends Entity { public age:number; public itemStack:ItemStack; diff --git a/server/entities/EntityLiving.ts b/server/entities/EntityLiving.ts index c01a39f..f27cb27 100644 --- a/server/entities/EntityLiving.ts +++ b/server/entities/EntityLiving.ts @@ -1,12 +1,12 @@ import { IReader, IWriter } from "bufferstuff"; -import { World } from "../World"; -import { Block } from "../blocks/Block"; -import { EntityStatus } from "../enums/EntityStatus"; -import { PacketEntityStatus } from "../packets/EntityStatus"; -import { Entity } from "./Entity"; -import { IEntity } from "./IEntity"; +import Block from "../blocks/Block"; +import Entity from "./Entity"; +import EntityStatus from "../enums/EntityStatus"; +import IEntity from "./IEntity"; +import PacketEntityStatus from "../packets/EntityStatus"; +import World from "../World"; -export class EntityLiving extends Entity { +export default class EntityLiving extends Entity { public timeInWater:number; public headHeight:number; public lastHealth:number; diff --git a/server/entities/IEntity.ts b/server/entities/IEntity.ts index f5bc8bd..2e9fa09 100644 --- a/server/entities/IEntity.ts +++ b/server/entities/IEntity.ts @@ -1,7 +1,7 @@ import AABB from "../AABB" import Vec3 from "../Vec3" -export interface IEntity { +export default interface IEntity { entityId:number, position:Vec3, motion:Vec3, diff --git a/server/entities/Player.ts b/server/entities/Player.ts index e419681..6fb422f 100644 --- a/server/entities/Player.ts +++ b/server/entities/Player.ts @@ -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 { EntityItem } from "./EntityItem"; -import { Entity } from "./Entity"; -import { PacketCollectItem } from "../packets/CollectItem"; -import { PacketPickupSpawn } from "../packets/PickupSpawn"; +import Block from "../blocks/Block"; +import Chunk from "../Chunk"; +import Entity from "./Entity"; +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; -export class Player extends EntityLiving { +export default class Player extends EntityLiving { public username:string; private server:MinecraftServer; private firstUpdate:boolean; diff --git a/server/enums/Animation.ts b/server/enums/Animation.ts index 8fe5ff5..df361eb 100644 --- a/server/enums/Animation.ts +++ b/server/enums/Animation.ts @@ -1,4 +1,4 @@ -export enum Animation { +enum Animation { None = 0, SwingArm = 1, Damage = 2, @@ -6,4 +6,6 @@ export enum Animation { Unknown102 = 102, Crouch = 104, Uncrouch = 105, -} \ No newline at end of file +} + +export default Animation; \ No newline at end of file diff --git a/server/enums/EntityStatus.ts b/server/enums/EntityStatus.ts index 17453e6..7f61196 100644 --- a/server/enums/EntityStatus.ts +++ b/server/enums/EntityStatus.ts @@ -1,8 +1,10 @@ -export enum EntityStatus { +enum EntityStatus { Unknown0, Unknown1, Hurt, Dead, Unknown4, Unknown5 -} \ No newline at end of file +} + +export default EntityStatus; \ No newline at end of file diff --git a/server/enums/MaxUses.ts b/server/enums/MaxUses.ts index c226e8c..f338791 100644 --- a/server/enums/MaxUses.ts +++ b/server/enums/MaxUses.ts @@ -1,7 +1,9 @@ -export enum MaxUses { +enum MaxUses { GOLD = 32, WOOD = 59, STONE = 131, IRON = 250, DIAMOND = 1561 -} \ No newline at end of file +} + +export default MaxUses; \ No newline at end of file diff --git a/server/enums/MetadataFieldType.ts b/server/enums/MetadataFieldType.ts index ff8d434..9fd1955 100644 --- a/server/enums/MetadataFieldType.ts +++ b/server/enums/MetadataFieldType.ts @@ -1,4 +1,4 @@ -export enum MetadataFieldType { +enum MetadataFieldType { Byte = 0, Short = 1, Int = 2, @@ -6,4 +6,6 @@ export enum MetadataFieldType { String = 4, Item = 5, Vector = 6 -} \ No newline at end of file +} + +export default MetadataFieldType; \ No newline at end of file diff --git a/server/enums/Packet.ts b/server/enums/Packet.ts index 01acab0..75d0373 100644 --- a/server/enums/Packet.ts +++ b/server/enums/Packet.ts @@ -1,5 +1,5 @@ // https://wiki.vg/index.php?title=Protocol&oldid=488 -export enum Packet { +enum Packet { KeepAlive = 0x00, LoginRequest = 0x01, Handshake = 0x02, @@ -49,4 +49,6 @@ export enum Packet { WindowItems = 0x68, DisconnectKick = 0xff -} \ No newline at end of file +} + +export default Packet; \ No newline at end of file diff --git a/server/enums/SaveCompressionType.ts b/server/enums/SaveCompressionType.ts index 4c70312..68f9fa7 100644 --- a/server/enums/SaveCompressionType.ts +++ b/server/enums/SaveCompressionType.ts @@ -1,5 +1,7 @@ -export enum SaveCompressionType { +enum SaveCompressionType { NONE = 0, DEFLATE = 1, XZ = 2 -} \ No newline at end of file +} + +export default SaveCompressionType; \ No newline at end of file diff --git a/server/enums/SoundEffects.ts b/server/enums/SoundEffects.ts index 88379c9..3612155 100644 --- a/server/enums/SoundEffects.ts +++ b/server/enums/SoundEffects.ts @@ -1,4 +1,4 @@ -export enum SoundEffects { +enum SoundEffects { CLICK2 = 1000, CLICK1 = 1001, BOW_FIRE = 1002, @@ -7,4 +7,6 @@ export enum SoundEffects { RECORD_PLAY = 1005, SMOKE = 2000, BLOCK_BREAK = 2001 -} \ No newline at end of file +} + +export default SoundEffects; \ No newline at end of file diff --git a/server/generators/IGenerator.ts b/server/generators/IGenerator.ts index 086e564..722ca82 100644 --- a/server/generators/IGenerator.ts +++ b/server/generators/IGenerator.ts @@ -1,5 +1,5 @@ -import { Chunk } from "../Chunk"; +import Chunk from "../Chunk"; -export interface IGenerator { +export default interface IGenerator { generate: (chunk:Chunk) => void } \ No newline at end of file diff --git a/server/generators/Flat.ts b/server/generators/terrain/Flat.ts similarity index 73% rename from server/generators/Flat.ts rename to server/generators/terrain/Flat.ts index 600a961..01ff1af 100644 --- a/server/generators/Flat.ts +++ b/server/generators/terrain/Flat.ts @@ -1,8 +1,8 @@ -import { Block } from "../blocks/Block"; -import { Chunk } from "../Chunk"; -import { IGenerator } from "./IGenerator"; +import Block from "../../blocks/Block"; +import Chunk from "../../Chunk"; +import IGenerator from "../IGenerator"; -export class FlatGenerator implements IGenerator { +export default class FlatGenerator implements IGenerator { public generate(chunk:Chunk) { for (let x = 0; x < 16; x++) { for (let z = 0; z < 16; z++) { diff --git a/server/generators/Hilly.ts b/server/generators/terrain/Hilly.ts similarity index 94% rename from server/generators/Hilly.ts rename to server/generators/terrain/Hilly.ts index 5858a93..c05f0db 100644 --- a/server/generators/Hilly.ts +++ b/server/generators/terrain/Hilly.ts @@ -1,12 +1,12 @@ -import { Block } from "../blocks/Block"; -import { Chunk } from "../Chunk"; -import { IGenerator } from "./IGenerator"; -import { Noise2D, makeNoise2D } from "../../external/OpenSimplex2D"; -import { Noise3D, makeNoise3D } from "../../external/OpenSimplex3D"; -import { QueuedBlockUpdate } from "../queuedUpdateTypes/BlockUpdate"; -import mulberry32 from "../mulberry32"; +import { Noise2D, makeNoise2D } from "../../../external/OpenSimplex2D"; +import { Noise3D, makeNoise3D } from "../../../external/OpenSimplex3D"; +import Block from "../../blocks/Block"; +import Chunk from "../../Chunk"; +import IGenerator from "../IGenerator"; +import mulberry32 from "../../mulberry32"; +import QueuedBlockUpdate from "../../queuedUpdateTypes/BlockUpdate"; -export class HillyGenerator implements IGenerator { +export default class HillyGenerator implements IGenerator { private seed:number; seedGenerator:() => number; diff --git a/server/generators/Nether.ts b/server/generators/terrain/Nether.ts similarity index 81% rename from server/generators/Nether.ts rename to server/generators/terrain/Nether.ts index 50d9544..4cce53b 100644 --- a/server/generators/Nether.ts +++ b/server/generators/terrain/Nether.ts @@ -1,12 +1,11 @@ -import { Block } from "../blocks/Block"; -import { Chunk } from "../Chunk"; -import { IGenerator } from "./IGenerator"; -import { Noise2D, makeNoise2D } from "../../external/OpenSimplex2D"; -import { Noise3D, makeNoise3D } from "../../external/OpenSimplex3D"; -import { QueuedBlockUpdate } from "../queuedUpdateTypes/BlockUpdate"; -import mulberry32 from "../mulberry32"; +import { Noise2D, makeNoise2D } from "../../../external/OpenSimplex2D"; +import { Noise3D, makeNoise3D } from "../../../external/OpenSimplex3D"; +import Block from "../../blocks/Block"; +import Chunk from "../../Chunk"; +import IGenerator from "../IGenerator"; +import mulberry32 from "../../mulberry32"; -export class NetherGenerator implements IGenerator { +export default class NetherGenerator implements IGenerator { private seed:number; seedGenerator:() => number; diff --git a/server/generators/NewOverworld.ts b/server/generators/terrain/NewOverworld.ts similarity index 85% rename from server/generators/NewOverworld.ts rename to server/generators/terrain/NewOverworld.ts index ca6501f..800fe76 100644 --- a/server/generators/NewOverworld.ts +++ b/server/generators/terrain/NewOverworld.ts @@ -1,12 +1,12 @@ -import { makeNoise2D, Noise2D } from "../../external/OpenSimplex2D"; -import { makeNoise3D, Noise3D } from "../../external/OpenSimplex3D"; -import { Block } from "../blocks/Block"; -import { Chunk } from "../Chunk"; -import mulberry32 from "../mulberry32"; -import { IGenerator } from "./IGenerator"; +import { makeNoise2D, Noise2D } from "../../../external/OpenSimplex2D"; +import { makeNoise3D, Noise3D } from "../../../external/OpenSimplex3D"; +import Block from "../../blocks/Block"; +import Chunk from "../../Chunk"; +import IGenerator from "../IGenerator"; +import mulberry32 from "../../mulberry32"; -export class NewOverworld implements IGenerator { +export default class NewOverworld implements IGenerator { private seed:number; seedGenerator:() => number; diff --git a/server/inventories/IInventory.ts b/server/inventories/IInventory.ts index 95ce96f..1c815a1 100644 --- a/server/inventories/IInventory.ts +++ b/server/inventories/IInventory.ts @@ -1,5 +1,5 @@ import { IReader, IWriter } from "bufferstuff"; -import { ItemStack } from "./ItemStack"; +import ItemStack from "./ItemStack"; export default interface IInventory { fromSave:(reader:IReader) => void, diff --git a/server/inventories/Inventory.ts b/server/inventories/Inventory.ts index 1599d76..5a77938 100644 --- a/server/inventories/Inventory.ts +++ b/server/inventories/Inventory.ts @@ -1,8 +1,8 @@ import { Endian, IReader, IWriter, createWriter } from "bufferstuff"; -import { ItemStack } from "./ItemStack"; import IInventory from "./IInventory"; +import ItemStack from "./ItemStack"; -export class Inventory implements IInventory { +export default class Inventory implements IInventory { public itemStacks:Array; private size:number; diff --git a/server/inventories/ItemStack.ts b/server/inventories/ItemStack.ts index e67e254..4ee1ffe 100644 --- a/server/inventories/ItemStack.ts +++ b/server/inventories/ItemStack.ts @@ -1,10 +1,9 @@ import { IReader, IWriter } from "bufferstuff"; -import { Block } from "../blocks/Block"; -import { IEntity } from "../entities/IEntity"; -import { Player } from "../entities/Player"; -import { Item } from "../items/Item"; +import Block from "../blocks/Block"; +import IEntity from "../entities/IEntity"; +import Item from "../items/Item"; -export class ItemStack { +export default class ItemStack { private static ITEMSTACK_ID_ADDER = 0; private readonly itemStackId:number; diff --git a/server/inventories/PlayerInventory.ts b/server/inventories/PlayerInventory.ts index e43ce2a..acf7fb4 100644 --- a/server/inventories/PlayerInventory.ts +++ b/server/inventories/PlayerInventory.ts @@ -1,8 +1,8 @@ -import { Player } from "../entities/Player"; -import { PacketSetSlot } from "../packets/SetSlot"; -import { PacketWindowItems } from "../packets/WindowItems"; -import { Inventory } from "./Inventory"; -import { ItemStack } from "./ItemStack"; +import Inventory from "./Inventory"; +import ItemStack from "./ItemStack"; +import PacketSetSlot from "../packets/SetSlot"; +import PacketWindowItems from "../packets/WindowItems"; +import Player from "../entities/Player"; export default class PlayerInventory extends Inventory { private player:Player; diff --git a/server/items/Item.ts b/server/items/Item.ts index 80a0d46..a0efaab 100644 --- a/server/items/Item.ts +++ b/server/items/Item.ts @@ -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 = new Array(); public maxStackSize:number; diff --git a/server/packets/Animation.ts b/server/packets/Animation.ts index b6bad6d..c5fe644 100644 --- a/server/packets/Animation.ts +++ b/server/packets/Animation.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketAnimation implements IPacket { +export default class PacketAnimation implements IPacket { public packetId = Packet.Animation; public entityId:number; public animation:number; diff --git a/server/packets/BlockChange.ts b/server/packets/BlockChange.ts index f24618a..34ed6b9 100644 --- a/server/packets/BlockChange.ts +++ b/server/packets/BlockChange.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketBlockChange implements IPacket { +export default class PacketBlockChange implements IPacket { public packetId = Packet.BlockChange; public x:number; public y:number; diff --git a/server/packets/Chat.ts b/server/packets/Chat.ts index 94334d6..35be85f 100644 --- a/server/packets/Chat.ts +++ b/server/packets/Chat.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketChat implements IPacket { +export default class PacketChat implements IPacket { public packetId = Packet.Chat; public message:string; diff --git a/server/packets/CollectItem.ts b/server/packets/CollectItem.ts index f6e5993..dbc4e34 100644 --- a/server/packets/CollectItem.ts +++ b/server/packets/CollectItem.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketCollectItem implements IPacket { +export default class PacketCollectItem implements IPacket { public packetId = Packet.CollectItem; public collectedEID:number; public collectorEID:number; diff --git a/server/packets/DestroyEntity.ts b/server/packets/DestroyEntity.ts index 1b772c6..71fb4ad 100644 --- a/server/packets/DestroyEntity.ts +++ b/server/packets/DestroyEntity.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketDestroyEntity implements IPacket { +export default class PacketDestroyEntity implements IPacket { public packetId = Packet.DestroyEntity; public entityId:number; diff --git a/server/packets/DisconnectKick.ts b/server/packets/DisconnectKick.ts index fdf6de6..872d2b2 100644 --- a/server/packets/DisconnectKick.ts +++ b/server/packets/DisconnectKick.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketDisconnectKick implements IPacket { +export default class PacketDisconnectKick implements IPacket { public packetId = Packet.DisconnectKick; public reason:string; diff --git a/server/packets/Entity.ts b/server/packets/Entity.ts index 31d99e9..b3ae339 100644 --- a/server/packets/Entity.ts +++ b/server/packets/Entity.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntity implements IPacket { +export default class PacketEntity implements IPacket { public packetId = Packet.Entity; public entityId:number; diff --git a/server/packets/EntityAction.ts b/server/packets/EntityAction.ts index 4bf1e8a..4440d42 100644 --- a/server/packets/EntityAction.ts +++ b/server/packets/EntityAction.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityAction implements IPacket { +export default class PacketEntityAction implements IPacket { public packetId = Packet.EntityAction; public entityId:number; public action:number; diff --git a/server/packets/EntityEquipment.ts b/server/packets/EntityEquipment.ts index 994fd96..b0bf65c 100644 --- a/server/packets/EntityEquipment.ts +++ b/server/packets/EntityEquipment.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityEquipment implements IPacket { +export default class PacketEntityEquipment implements IPacket { public packetId = Packet.EntityEquipment; public entityId:number; public slot:number; diff --git a/server/packets/EntityLook.ts b/server/packets/EntityLook.ts index 5147b52..6d44a4f 100644 --- a/server/packets/EntityLook.ts +++ b/server/packets/EntityLook.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityLook implements IPacket { +export default class PacketEntityLook implements IPacket { public packetId = Packet.EntityLook; public entityId:number; public yaw:number; diff --git a/server/packets/EntityLookRelativeMove.ts b/server/packets/EntityLookRelativeMove.ts index 21c4857..56bd282 100644 --- a/server/packets/EntityLookRelativeMove.ts +++ b/server/packets/EntityLookRelativeMove.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityLookRelativeMove implements IPacket { +export default class PacketEntityLookRelativeMove implements IPacket { public packetId = Packet.EntityLookRelativeMove; public entityId:number; public dX:number; diff --git a/server/packets/EntityMetadata.ts b/server/packets/EntityMetadata.ts index 8bf3e06..e8336f8 100644 --- a/server/packets/EntityMetadata.ts +++ b/server/packets/EntityMetadata.ts @@ -1,10 +1,10 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; const EMPTY_BUFFER = Buffer.alloc(0); -export class PacketEntityMetadata implements IPacket { +export default class PacketEntityMetadata implements IPacket { public packetId = Packet.EntityMetadata; public entityId:number; public metadata:Buffer; diff --git a/server/packets/EntityRelativeMove.ts b/server/packets/EntityRelativeMove.ts index 6669416..b1b60ec 100644 --- a/server/packets/EntityRelativeMove.ts +++ b/server/packets/EntityRelativeMove.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityRelativeMove implements IPacket { +export default class PacketEntityRelativeMove implements IPacket { public packetId = Packet.EntityRelativeMove; public entityId:number; public dX:number; diff --git a/server/packets/EntityStatus.ts b/server/packets/EntityStatus.ts index ad6af51..8977972 100644 --- a/server/packets/EntityStatus.ts +++ b/server/packets/EntityStatus.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityStatus implements IPacket { +export default class PacketEntityStatus implements IPacket { public packetId = Packet.EntityStatus; public entityId:number; public status:number; diff --git a/server/packets/EntityTeleport.ts b/server/packets/EntityTeleport.ts index bcd3bfc..0de7932 100644 --- a/server/packets/EntityTeleport.ts +++ b/server/packets/EntityTeleport.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketEntityTeleport implements IPacket { +export default class PacketEntityTeleport implements IPacket { public packetId = Packet.EntityTeleport; public entityId:number; public x:number; diff --git a/server/packets/EntityVelocity.ts b/server/packets/EntityVelocity.ts index 546ad3b..b8bca6c 100644 --- a/server/packets/EntityVelocity.ts +++ b/server/packets/EntityVelocity.ts @@ -1,6 +1,6 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; const MOTION_MAX = 3.9; function maxMotion(value:number) { @@ -13,7 +13,7 @@ function maxMotion(value:number) { return value; } -export class PacketEntityVelocity implements IPacket { +export default class PacketEntityVelocity implements IPacket { public packetId = Packet.EntityVelocity; public entityId:number; public x:number; diff --git a/server/packets/Handshake.ts b/server/packets/Handshake.ts index 34e0fbd..a49a64a 100644 --- a/server/packets/Handshake.ts +++ b/server/packets/Handshake.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketHandshake implements IPacket { +export default class PacketHandshake implements IPacket { public packetId:Packet = Packet.Handshake; private username:string; diff --git a/server/packets/HoldingChange.ts b/server/packets/HoldingChange.ts index 3d2c6a8..43c482f 100644 --- a/server/packets/HoldingChange.ts +++ b/server/packets/HoldingChange.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketHoldingChange implements IPacket { +export default class PacketHoldingChange implements IPacket { public packetId = Packet.HoldingChange; public slotId:number; diff --git a/server/packets/IPacket.ts b/server/packets/IPacket.ts index 9d29751..7eb2e82 100644 --- a/server/packets/IPacket.ts +++ b/server/packets/IPacket.ts @@ -1,7 +1,7 @@ import { IReader } from "bufferstuff"; -import { Packet } from "../enums/Packet"; +import Packet from "../enums/Packet"; -export interface IPacket { +export default interface IPacket { packetId: Packet, readData: (reader:IReader) => IPacket, writeData: () => Buffer|Promise diff --git a/server/packets/KeepAlive.ts b/server/packets/KeepAlive.ts index 897b7b4..0d4bdbb 100644 --- a/server/packets/KeepAlive.ts +++ b/server/packets/KeepAlive.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketKeepAlive implements IPacket { +export default class PacketKeepAlive implements IPacket { public packetId = Packet.KeepAlive; private static readonly KeepAliveBuffer:Buffer = createWriter(Endian.BE, 1).writeByte(Packet.KeepAlive).toBuffer(); diff --git a/server/packets/LoginRequest.ts b/server/packets/LoginRequest.ts index 2abb764..902ed2f 100644 --- a/server/packets/LoginRequest.ts +++ b/server/packets/LoginRequest.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketLoginRequest implements IPacket { +export default class PacketLoginRequest implements IPacket { public packetId = Packet.LoginRequest; public protocolVersion:number; public username:string; diff --git a/server/packets/MapChunk.ts b/server/packets/MapChunk.ts index 8bf1426..36b39de 100644 --- a/server/packets/MapChunk.ts +++ b/server/packets/MapChunk.ts @@ -1,10 +1,10 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { Chunk } from "../Chunk"; import { deflate } from "zlib"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import Chunk from "../Chunk"; +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 x:number; public y:number; diff --git a/server/packets/NamedEntitySpawn.ts b/server/packets/NamedEntitySpawn.ts index 4363f1a..fff4236 100644 --- a/server/packets/NamedEntitySpawn.ts +++ b/server/packets/NamedEntitySpawn.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketNamedEntitySpawn implements IPacket { +export default class PacketNamedEntitySpawn implements IPacket { public packetId = Packet.NamedEntitySpawn; public entityId:number; public playerName:string; diff --git a/server/packets/PickupSpawn.ts b/server/packets/PickupSpawn.ts index d9fa560..ca9b879 100644 --- a/server/packets/PickupSpawn.ts +++ b/server/packets/PickupSpawn.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPickupSpawn implements IPacket { +export default class PacketPickupSpawn implements IPacket { public packetId = Packet.PickupSpawn; public entityId:number; public item:number; diff --git a/server/packets/Player.ts b/server/packets/Player.ts index 422cd27..46d729d 100644 --- a/server/packets/Player.ts +++ b/server/packets/Player.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPlayer implements IPacket { +export default class PacketPlayer implements IPacket { public packetId = Packet.Player; public onGround:boolean; diff --git a/server/packets/PlayerBlockPlacement.ts b/server/packets/PlayerBlockPlacement.ts index c54937c..32334ea 100644 --- a/server/packets/PlayerBlockPlacement.ts +++ b/server/packets/PlayerBlockPlacement.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPlayerBlockPlacement implements IPacket { +export default class PacketPlayerBlockPlacement implements IPacket { public packetId = Packet.PlayerBlockPlacement; public x:number; public y:number; diff --git a/server/packets/PlayerDigging.ts b/server/packets/PlayerDigging.ts index 558ec1f..424b864 100644 --- a/server/packets/PlayerDigging.ts +++ b/server/packets/PlayerDigging.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPlayerDigging implements IPacket { +export default class PacketPlayerDigging implements IPacket { public packetId = Packet.PlayerDigging; public status:number; public x:number; diff --git a/server/packets/PlayerLook.ts b/server/packets/PlayerLook.ts index d0b3954..ab02c09 100644 --- a/server/packets/PlayerLook.ts +++ b/server/packets/PlayerLook.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPlayerLook implements IPacket { +export default class PacketPlayerLook implements IPacket { public packetId = Packet.Player; public yaw:number; public pitch:number; diff --git a/server/packets/PlayerPosition.ts b/server/packets/PlayerPosition.ts index 8d6d992..9519c09 100644 --- a/server/packets/PlayerPosition.ts +++ b/server/packets/PlayerPosition.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPlayerPosition implements IPacket { +export default class PacketPlayerPosition implements IPacket { public packetId = Packet.PlayerPosition; public x:number; public y:number; diff --git a/server/packets/PlayerPositionLook.ts b/server/packets/PlayerPositionLook.ts index 8357892..7aa8fbf 100644 --- a/server/packets/PlayerPositionLook.ts +++ b/server/packets/PlayerPositionLook.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPlayerPositionLook implements IPacket { +export default class PacketPlayerPositionLook implements IPacket { public packetId = Packet.PlayerPosition; public x:number; public y:number; diff --git a/server/packets/PreChunk.ts b/server/packets/PreChunk.ts index 61d0899..f597f17 100644 --- a/server/packets/PreChunk.ts +++ b/server/packets/PreChunk.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketPreChunk implements IPacket { +export default class PacketPreChunk implements IPacket { public packetId = Packet.PreChunk; public x:number; public z:number; diff --git a/server/packets/Respawn.ts b/server/packets/Respawn.ts index 1ffe08f..5a5ad39 100644 --- a/server/packets/Respawn.ts +++ b/server/packets/Respawn.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketRespawn implements IPacket { +export default class PacketRespawn implements IPacket { public packetId = Packet.Respawn; public dimension:number; diff --git a/server/packets/SetSlot.ts b/server/packets/SetSlot.ts index 51abd7b..d307b9a 100644 --- a/server/packets/SetSlot.ts +++ b/server/packets/SetSlot.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketSetSlot implements IPacket { +export default class PacketSetSlot implements IPacket { public packetId = Packet.SetSlot; public windowId:number; public slot:number; diff --git a/server/packets/SoundEffect.ts b/server/packets/SoundEffect.ts index 60b5494..624f24a 100644 --- a/server/packets/SoundEffect.ts +++ b/server/packets/SoundEffect.ts @@ -1,9 +1,9 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; -import { SoundEffects } from "../enums/SoundEffects"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; +import SoundEffects from "../enums/SoundEffects"; -export class PacketSoundEffect implements IPacket { +export default class PacketSoundEffect implements IPacket { public packetId = Packet.SoundEffect; public effectId:SoundEffects; public x:number; diff --git a/server/packets/SpawnPosition.ts b/server/packets/SpawnPosition.ts index 7d099a6..d461900 100644 --- a/server/packets/SpawnPosition.ts +++ b/server/packets/SpawnPosition.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketSpawnPosition implements IPacket { +export default class PacketSpawnPosition implements IPacket { public packetId = Packet.SpawnPosition; public x:number; public y:number; diff --git a/server/packets/TimeUpdate.ts b/server/packets/TimeUpdate.ts index c48dbfb..dc9429c 100644 --- a/server/packets/TimeUpdate.ts +++ b/server/packets/TimeUpdate.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketTimeUpdate implements IPacket { +export default class PacketTimeUpdate implements IPacket { public packetId = Packet.TimeUpdate; public time:bigint; diff --git a/server/packets/UpdateHealth.ts b/server/packets/UpdateHealth.ts index 221ae6e..a5272d3 100644 --- a/server/packets/UpdateHealth.ts +++ b/server/packets/UpdateHealth.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketUpdateHealth implements IPacket { +export default class PacketUpdateHealth implements IPacket { public packetId = Packet.UpdateHealth; public health:number; diff --git a/server/packets/UseEntity.ts b/server/packets/UseEntity.ts index 34d1d7b..ddaf881 100644 --- a/server/packets/UseEntity.ts +++ b/server/packets/UseEntity.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketUseEntity implements IPacket { +export default class PacketUseEntity implements IPacket { public packetId = Packet.UseEntity; public userId:number; public targetId:number; diff --git a/server/packets/WindowClick.ts b/server/packets/WindowClick.ts index 58b4abf..d2fa058 100644 --- a/server/packets/WindowClick.ts +++ b/server/packets/WindowClick.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketWindowClick implements IPacket { +export default class PacketWindowClick implements IPacket { public packetId = Packet.WindowClick; public windowId:number; public slot:number; diff --git a/server/packets/WindowItems.ts b/server/packets/WindowItems.ts index 06d2b67..3b80d03 100644 --- a/server/packets/WindowItems.ts +++ b/server/packets/WindowItems.ts @@ -1,8 +1,8 @@ import { createWriter, IReader, Endian } from "bufferstuff"; -import { IPacket } from "./IPacket"; -import { Packet } from "../enums/Packet"; +import IPacket from "./IPacket"; +import Packet from "../enums/Packet"; -export class PacketWindowItems implements IPacket { +export default class PacketWindowItems implements IPacket { public packetId = Packet.WindowItems; public windowId:number; public count:number; diff --git a/server/queuedUpdateTypes/BlockUpdate.ts b/server/queuedUpdateTypes/BlockUpdate.ts index 96e4e7d..1fd2370 100644 --- a/server/queuedUpdateTypes/BlockUpdate.ts +++ b/server/queuedUpdateTypes/BlockUpdate.ts @@ -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 x:number; public y:number; diff --git a/server/queuedUpdateTypes/IQueuedUpdate.ts b/server/queuedUpdateTypes/IQueuedUpdate.ts index b60adcf..7cf9b13 100644 --- a/server/queuedUpdateTypes/IQueuedUpdate.ts +++ b/server/queuedUpdateTypes/IQueuedUpdate.ts @@ -1 +1 @@ -export interface IQueuedUpdate {} \ No newline at end of file +export default interface IQueuedUpdate {} \ No newline at end of file diff --git a/tooling/fileSmasher.ts b/tooling/fileSmasher.ts index 7f9f42a..0fb6882 100644 --- a/tooling/fileSmasher.ts +++ b/tooling/fileSmasher.ts @@ -57,7 +57,7 @@ for (const line of splitLines) { } // Fix up classes, interfaces and such. //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"));