minor tile entity progress
All checks were successful
Node.js Build / build (20.x) (push) Successful in 5m20s
All checks were successful
Node.js Build / build (20.x) (push) Successful in 5m20s
This commit is contained in:
parent
18ff5a5910
commit
d0c16ba8db
3 changed files with 31 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
enum TileEntityType {
|
||||
Unknown,
|
||||
Chest
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { IReader, IWriter } from "bufferstuff";
|
||||
import Block from "../blocks/Block";
|
||||
import TileEntityType from "../enums/TileEntityType";
|
||||
import Vec3 from "../Vec3";
|
||||
import TileEntityChest from "./TileEntityChest";
|
||||
|
||||
export default class TileEntity {
|
||||
private readonly type: TileEntityType;
|
||||
|
@ -12,4 +14,22 @@ export default class TileEntity {
|
|||
this.forBlockId = forBlockId;
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
10
server/tileentities/TileEntityChest.ts
Normal file
10
server/tileentities/TileEntityChest.ts
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue