mc-beta-server/server/blocks/BlockBehaviourChest.ts
Holly d82b86546a
All checks were successful
Node.js Build / build (20.x) (push) Successful in 5m18s
implement tile entity add + remove, and make loading more robust.
2024-11-25 22:28:33 +00:00

16 lines
No EOL
581 B
TypeScript

import TileEntityChest from "../tileentities/TileEntityChest";
import Vec3 from "../Vec3";
import World from "../World";
import BlockBehaviour from "./BlockBehaviour";
export default class BlockBehaviourChest extends BlockBehaviour {
public placed(world:World, x:number, y:number, z:number) {
const chunk = world.getChunk(x >> 4, z >> 4);
chunk.setTileEntity(new TileEntityChest(new Vec3(x & 0xf, y, z & 0xf)), x, y, z);
}
public destroyed(world:World, x:number, y:number, z:number) {
const chunk = world.getChunk(x >> 4, z >> 4);
chunk.removeTileEntity(x, y, z);
}
}