Lighting system
This commit is contained in:
@@ -98,6 +98,16 @@ interface BlockStateVariant {
|
||||
export const RENDER_LAYERS = ["solid", "cutout", "translucent"] as const;
|
||||
export type RenderLayer = typeof RENDER_LAYERS[number];
|
||||
|
||||
// like minecraft: solid blocks stop light, everything else lets it through unless it says otherwise
|
||||
export function block_light_opacity(block: BlockRegistry | undefined): number {
|
||||
if (!block) return 0;
|
||||
return block.light_opacity ?? ((block.render_layer ?? "solid") === "solid" ? 15 : 0);
|
||||
}
|
||||
|
||||
export function block_light_emission(block: BlockRegistry | undefined): number {
|
||||
return block?.light_emission ?? 0;
|
||||
}
|
||||
|
||||
export interface BlockRegistry {
|
||||
id: string;
|
||||
textures: string | TextureSideTopBottom | TextureFront;
|
||||
@@ -105,6 +115,10 @@ export interface BlockRegistry {
|
||||
render_layer?: RenderLayer;
|
||||
// hide faces between two of this block, like glass and water. defaults to true for translucent blocks
|
||||
cull_same?: boolean;
|
||||
// light level 0-15 it gives off
|
||||
light_emission?: number;
|
||||
// how much light going through it loses, 0-15. see block_light_opacity for the default
|
||||
light_opacity?: number;
|
||||
alpha?: number;
|
||||
|
||||
has_collision: boolean;
|
||||
|
||||
Reference in New Issue
Block a user