// Copyright 2023 drey7925 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package perovskite.protocol.blocks; import "render.proto"; // Definition of a block type. // In the future, server-side code may be able to define custom properties for // individual instances of a block; the mechanism and structure for this is not // defined yet. message BlockTypeDef { // Identifier for the block. Lowest 12 bits are 0 here, since those bits are // used for block variants. The values of this field are assigned by the // perovskite server. uint32 id = 1; // Unique name used to refer to the block in scripts and commands, e.g. // base:dirt string short_name = 2; // How long the block should take to dig with a tool that uses scaled_time // = 1.0 double base_dig_time = 3; // Groups that this item pertains to repeated string groups = 4; // When a tool is digging this block, multiply the effective wear by this // amount. double wear_multiplier = 5; // How much light the block emits uint32 light_emission = 6; // Whether the block allows light to propagate through it bool allow_light_propagation = 7; // How the client should render the block oneof render_info { Empty empty = 10; // The block is a solid cube CubeRenderInfo cube = 11; // The block is a plant-like object, with transparency; the texture is applied as an X shape. PlantLikeRenderInfo plant_like = 12; // The block contains many rectangular prisms, each with its own texture and extent. AxisAlignedBoxes axis_aligned_boxes = 13; }; // How the client should handle physics when interacting with the block oneof physics_info { Empty air = 20; Empty solid = 21; FluidPhysicsInfo fluid = 22; // Any texture/rendering related info is ignored; rotation and variant_mask are used AxisAlignedBoxes solid_custom_collisionboxes = 23; } } // A rectangular prism. 0,0,0 is at the center of the block. A full cube spans (-0.5, 0.5) on // each axis. // y is given with positive upwards. message AxisAlignedBox { float x_min = 1; float y_min = 2; float z_min = 3; float x_max = 4; float y_max = 5; float z_max = 6; perovskite.protocol.render.TextureReference tex_left = 7; perovskite.protocol.render.TextureReference tex_right = 8; perovskite.protocol.render.TextureReference tex_top = 9; perovskite.protocol.render.TextureReference tex_bottom = 10; perovskite.protocol.render.TextureReference tex_front = 11; perovskite.protocol.render.TextureReference tex_back = 12; AxisAlignedBoxRotation rotation = 13; // If nonzero, this box will only be rendered if variant & variant_mask != 0. uint32 variant_mask = 14; // If set, transform y values on the top face from y_max to (y_max + top_slope_x * x + top_slope_z * z) float top_slope_x = 15; float top_slope_z = 16; // Same, but for the bottom face float bottom_slope_x = 17; float bottom_slope_z = 18; } enum AxisAlignedBoxRotation { // No rotation is performed AXIS_ALIGNED_BOX_ROTATION_NONE = 0; // Bottom two bits of variant 0/1/2/3 cause the block to point its front face toward Z-/X-/Z+/X+, respectively. // The top and bottom textures are rotated to line up. AXIS_ALIGNED_BOX_ROTATION_NESW = 1; } message AxisAlignedBoxes { repeated AxisAlignedBox boxes = 1; } message Empty {} // Describes the way a cube-shaped block should be rendered. enum CubeRenderMode { // Behavior is unspecified CUBE_RENDER_MODE_UNSPECIFIED = 0; // The textures are opaque everywhere. // Behavior is unspecified (graphical glitches may occur) if the texture // contains transparent or translucent pixels. CUBE_RENDER_MODE_SOLID_OPAQUE = 1; // The textures contain both pixels with alpha=1 and pixels with alpha=0. // This mode takes care of properly dealing with transparent pixels but not // translucent pixels. CUBE_RENDER_MODE_TRANSPARENT = 2; // The textures contain translucent pixels. // This mode's behavior is still TBD, and is subject to change. CUBE_RENDER_MODE_TRANSLUCENT = 3; } message CubeRenderInfo { perovskite.protocol.render.TextureReference tex_left = 1; perovskite.protocol.render.TextureReference tex_right = 2; perovskite.protocol.render.TextureReference tex_top = 3; perovskite.protocol.render.TextureReference tex_bottom = 4; perovskite.protocol.render.TextureReference tex_front = 5; perovskite.protocol.render.TextureReference tex_back = 6; CubeRenderMode render_mode = 7; CubeVariantEffect variant_effect = 8; } message PlantLikeRenderInfo { // The texture for this block. perovskite.protocol.render.TextureReference tex = 1; // how much the top of the block should wave over time // This will be the amplitude, given in units of 1.0 = entire width of block. float wave_effect_scale = 2; } enum CubeVariantEffect { // The variant has no effect on rendering CUBE_VARIANT_EFFECT_NONE = 0; // Bottom two bits of variant 0/1/2/3 cause the block to point its front face toward Z-/X-/Z+/X+, respectively. // The top and bottom textures are rotated to line up. CUBE_VARIANT_EFFECT_ROTATE_NESW = 1; // Variant 0xfff is a full cube representing a source of this liquid. Variants 0-8 indicate flowing instances of this liquid. // Variant 0xfff has the same appearance as variant 0, but game logic may choose to make a distinction (i.e. 0xfff can be collected // into a bucket and creates other variants around it, variants 0-8 can't) // Behavior for variants 9 - 0xffe is unspecified (may become specified in the future) - builtin and default game code guarantees not // to crash upon those variants, but may act arbitrarily // // Note - this may be superseded by its own render_info oneof type in the future. CUBE_VARIANT_EFFECT_LIQUID = 2; } message FluidPhysicsInfo { // Speed of movement when in the fluid, blocks/sec double horizontal_speed = 1; // Speed when not pressing jump or lower keys, blocks/sec. Positive means // upward double vertical_speed = 2; // Speed when pressing jump. Positive means upward double jump_speed = 3; // Speed when pressing the lower key. Positive means upward. double sink_speed = 4; // How deep surface effects extend for, in blocks. double surface_thickness = 5; // Speed of movement when in the fluid, blocks/sec double surf_horizontal_speed = 6; // Speed when not pressing jump or lower keys, blocks/sec. Positive means // upward double surf_vertical_speed = 7; // Speed when pressing jump. Positive means upward double surf_jump_speed = 8; // Speed when pressing the lower key. Positive means upward. double surf_sink_speed = 9; } // Options available for the interact key when facing a block message InteractKeyOption { // internal ID, assigned and managed by perovskite core uint32 id = 1; // human readable label in-game string label = 2; } message BlockTypeAssignment { string short_name = 1; uint32 id = 2; } message ServerBlockTypeAssignments { repeated BlockTypeAssignment block_type = 1; }