convert whole project to use default exports

This commit is contained in:
Holly Stubbs 2024-10-26 14:24:38 +01:00
parent 7d4445112b
commit 78c894a94d
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
90 changed files with 386 additions and 377 deletions

View file

@ -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,

View file

@ -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;

View file

@ -1,4 +1,4 @@
export class NibbleArray {
export default class NibbleArray {
private array:Uint8Array;
public constructor(size:number|ArrayBuffer|Uint8Array) {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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) {

View file

@ -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;
}

View file

@ -1,4 +1,4 @@
export class TrackedProperty<T> {
export default class TrackedProperty<T> {
private trackedValue?:T;
private updateCallback?:(value:T) => void;

View file

@ -1,4 +1,4 @@
export class Vec2 {
export default class Vec2 {
public x:number;
public y:number;

View file

@ -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);

View file

@ -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;

View file

@ -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<Block> = new Array<Block>();

View file

@ -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);

View file

@ -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) {

View file

@ -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) {}

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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;
}

View file

@ -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) {

View file

@ -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,

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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,
}
}
export default Animation;

View file

@ -1,8 +1,10 @@
export enum EntityStatus {
enum EntityStatus {
Unknown0,
Unknown1,
Hurt,
Dead,
Unknown4,
Unknown5
}
}
export default EntityStatus;

View file

@ -1,7 +1,9 @@
export enum MaxUses {
enum MaxUses {
GOLD = 32,
WOOD = 59,
STONE = 131,
IRON = 250,
DIAMOND = 1561
}
}
export default MaxUses;

View file

@ -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
}
}
export default MetadataFieldType;

View file

@ -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
}
}
export default Packet;

View file

@ -1,5 +1,7 @@
export enum SaveCompressionType {
enum SaveCompressionType {
NONE = 0,
DEFLATE = 1,
XZ = 2
}
}
export default SaveCompressionType;

View file

@ -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
}
}
export default SoundEffects;

View file

@ -1,5 +1,5 @@
import { Chunk } from "../Chunk";
import Chunk from "../Chunk";
export interface IGenerator {
export default interface IGenerator {
generate: (chunk:Chunk) => void
}

View file

@ -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++) {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -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<ItemStack | null>;
private size:number;

View file

@ -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;

View file

@ -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;

View file

@ -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 maxStackSize:number;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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<Buffer>

View file

@ -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();

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1 +1 @@
export interface IQueuedUpdate {}
export default interface IQueuedUpdate {}

View file

@ -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"));