From 18ff5a5910b3b40b21f030f81c958b32a8c431da Mon Sep 17 00:00:00 2001 From: Holly Date: Sun, 17 Nov 2024 08:26:35 +0000 Subject: [PATCH] tile entity base --- server/Chunk.ts | 4 ++++ server/enums/TileEntityType.ts | 5 +++++ server/tileentities/TileEntity.ts | 15 +++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 server/enums/TileEntityType.ts create mode 100644 server/tileentities/TileEntity.ts diff --git a/server/Chunk.ts b/server/Chunk.ts index 3247034..36f056a 100644 --- a/server/Chunk.ts +++ b/server/Chunk.ts @@ -4,6 +4,7 @@ import NibbleArray from "../nibbleArray"; import Player from "./entities/Player"; import QueuedBlockUpdate from "./queuedUpdateTypes/BlockUpdate"; import World from "./World"; +import TileEntity from "./tileentities/TileEntity"; export default class Chunk { private readonly MAX_HEIGHT:number = 128; @@ -16,6 +17,8 @@ export default class Chunk { public savingToDisk:boolean = false; public forceLoaded:boolean = false; + private tileEntities:FunkyArray; + private blocks:Uint8Array; private metadata:NibbleArray; public skyLight:NibbleArray; @@ -30,6 +33,7 @@ export default class Chunk { this.x = x; this.z = z; this.playersInChunk = new FunkyArray(); + this.tileEntities = new FunkyArray(); if (generateOrBlockData instanceof Uint8Array && metadata instanceof Uint8Array && blockLight instanceof Uint8Array && skyLight instanceof Uint8Array) { this.blocks = new Uint8Array(generateOrBlockData); diff --git a/server/enums/TileEntityType.ts b/server/enums/TileEntityType.ts new file mode 100644 index 0000000..7f0e523 --- /dev/null +++ b/server/enums/TileEntityType.ts @@ -0,0 +1,5 @@ +enum TileEntityType { + Chest +} + +export default TileEntityType; \ No newline at end of file diff --git a/server/tileentities/TileEntity.ts b/server/tileentities/TileEntity.ts new file mode 100644 index 0000000..d43f67b --- /dev/null +++ b/server/tileentities/TileEntity.ts @@ -0,0 +1,15 @@ +import Block from "../blocks/Block"; +import TileEntityType from "../enums/TileEntityType"; +import Vec3 from "../Vec3"; + +export default class TileEntity { + private readonly type: TileEntityType; + private readonly forBlockId: Block; + private readonly position: Vec3; + + public constructor(type: TileEntityType, forBlockId: Block, position: Vec3) { + this.type = type; + this.forBlockId = forBlockId; + this.position = position; + } +} \ No newline at end of file