Server authority
This commit is contained in:
+6
-9
@@ -1,5 +1,4 @@
|
||||
import { AssetManager } from "../client/assets.ts";
|
||||
import { ID_MASK, SpriteRegion, STATE_SHIFT } from "./constants.ts";
|
||||
import { ID_MASK, STATE_SHIFT } from "./constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "./everything_registry.ts";
|
||||
|
||||
export function point_inside_rec(
|
||||
@@ -16,13 +15,6 @@ export function point_inside_rec(
|
||||
point_y < rec_y + rec_h;
|
||||
}
|
||||
|
||||
type TexturesInfo = Record<string, SpriteRegion>;
|
||||
|
||||
export function get_sprite_region(id: string): SpriteRegion {
|
||||
const textures_info = AssetManager.instance.get<TexturesInfo>("bworld:textures_info");
|
||||
return textures_info?.[id] ?? { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
export function distance_point_rectangle(px: number, py: number, sqx: number, sqy: number, sqw: number, sqh: number) {
|
||||
const x0 = sqx;
|
||||
const y0 = sqy;
|
||||
@@ -106,3 +98,8 @@ function compile_block_states(block_info: BlockRegistry) {
|
||||
return { name: s.name, mask, shift };
|
||||
});
|
||||
}
|
||||
|
||||
// numeric so looking chunks up doesnt allocate a string every time, fine for |x|, |z| < 32768
|
||||
export function chunk_key(x: number, z: number) {
|
||||
return (x + 32768) * 65536 + (z + 32768);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user