Basic crops system
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ItemStack } from "./inventory.ts";
|
||||
import type { BlockVariant } from "./block_models.ts";
|
||||
|
||||
export class EverythingRegistry {
|
||||
static #key_to_id = new Map<string, Map<string, number>>();
|
||||
@@ -65,16 +66,9 @@ export class EverythingRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
interface TextureSideTopBottom {
|
||||
top: string;
|
||||
bottom: string;
|
||||
side: string;
|
||||
}
|
||||
|
||||
interface TextureFront {
|
||||
front: string;
|
||||
side: string;
|
||||
}
|
||||
// one texture for everything, or the model's texture variables: { top, bottom, side } or { front, side } for
|
||||
// cubes, { crop } for engine:crop and so on
|
||||
export type BlockTextures = string | Record<string, string>;
|
||||
|
||||
export interface BlockStateDefinition {
|
||||
name: string;
|
||||
@@ -88,11 +82,6 @@ interface CompiledStateDefinition {
|
||||
shift: number;
|
||||
}
|
||||
|
||||
interface BlockStateVariant {
|
||||
model: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
// solid: fully opaque. cutout: texels are either opaque or see-through (leaves).
|
||||
// translucent: blended and sorted back to front (water, glass)
|
||||
export const RENDER_LAYERS = ["solid", "cutout", "translucent"] as const;
|
||||
@@ -110,7 +99,9 @@ export function block_light_emission(block: BlockRegistry | undefined): number {
|
||||
|
||||
export interface BlockRegistry {
|
||||
id: string;
|
||||
textures: string | TextureSideTopBottom | TextureFront;
|
||||
textures: BlockTextures;
|
||||
// the block model, engine:cube when not set. see common/block_models.ts
|
||||
model?: string;
|
||||
// solid when not set. anything else doesn't hide its neighbors' faces
|
||||
render_layer?: RenderLayer;
|
||||
// hide faces between two of this block, like glass and water. defaults to true for translucent blocks
|
||||
@@ -128,7 +119,8 @@ export interface BlockRegistry {
|
||||
drop_table?: string;
|
||||
|
||||
states?: BlockStateDefinition[];
|
||||
variants?: Record<string, BlockStateVariant>;
|
||||
// a different model or textures for some states, by conditions like "age=7". the first match wins
|
||||
variants?: Record<string, BlockVariant>;
|
||||
|
||||
// right clicking it does something instead of placing a block, clients don't predict placing against it.
|
||||
// behavior runs on the server, see server/game/blocks.ts
|
||||
|
||||
Reference in New Issue
Block a user