minor tile entity progress
All checks were successful
Node.js Build / build (20.x) (push) Successful in 5m20s

This commit is contained in:
Holly Stubbs 2024-11-22 23:51:27 +00:00
parent 18ff5a5910
commit d0c16ba8db
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
3 changed files with 31 additions and 0 deletions

View file

@ -1,4 +1,5 @@
enum TileEntityType { enum TileEntityType {
Unknown,
Chest Chest
} }

View file

@ -1,6 +1,8 @@
import { IReader, IWriter } from "bufferstuff";
import Block from "../blocks/Block"; import Block from "../blocks/Block";
import TileEntityType from "../enums/TileEntityType"; import TileEntityType from "../enums/TileEntityType";
import Vec3 from "../Vec3"; import Vec3 from "../Vec3";
import TileEntityChest from "./TileEntityChest";
export default class TileEntity { export default class TileEntity {
private readonly type: TileEntityType; private readonly type: TileEntityType;
@ -12,4 +14,22 @@ export default class TileEntity {
this.forBlockId = forBlockId; this.forBlockId = forBlockId;
this.position = position; this.position = position;
} }
public fromSave(reader:IReader) : TileEntity {
let tileEntity:TileEntity;
const type: TileEntityType = reader.readUByte();
const forBlock = Block.blocks[reader.readUByte()];
const position = new Vec3(reader.readUByte(), reader.readUByte(), reader.readUByte());
if (type === TileEntityType.Chest) {
tileEntity = new TileEntityChest(type, forBlock, position);
} else {
tileEntity = new TileEntity(type, forBlock, position);
}
return tileEntity;
}
public toSave(writer:IWriter) {
}
} }

View file

@ -0,0 +1,10 @@
import Block from "../blocks/Block";
import TileEntityType from "../enums/TileEntityType";
import TileEntity from "./TileEntity";
import Vec3 from "../Vec3";
export default class TileEntityChest extends TileEntity {
public constructor(type: TileEntityType, forBlockId: Block, position: Vec3) {
super(type, forBlockId, position);
}
}