// 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.items; import "render.proto"; message Empty {} message ItemDef { // 1 is reserved if a numeric ID is necessary in the future // Unique name for the item, e.g. base:pick_diamond string short_name = 2; // In-game display name, e.g. "Diamond pickaxe" string display_name = 3; // Texture to show in the inventory. Ignored if block_apperance is set perovskite.protocol.render.TextureReference inventory_texture = 4; // Groups for this item. This is NOT the same as the groups that this item // can dig; see InteractionRule for that repeated string groups = 5; // If set, disregard inventory_texture and render this block instead. string block_apperance = 6; // Optional oneof. If unset, item neither stacks nor wears out oneof quantity_type { // If set, the item stacks up to N copies. Stacks can be split up. uint32 stack = 11; // If set, the item has wear (from 0 to N) but does not stack. // Note that items don't automatically destroy themselves when wear reaches // zero, unless the item's callback does so explicitly // // Item cannot be split up. uint32 wear = 12; } // Rules on how this tool ought to behave. The first matching rule applies. repeated InteractionRule interaction_rules = 21; } message InteractionRule { // The block groups (see the `group` field in BlockTypeDef) that the rule // applies to. If *all* groups for the block match any of the groups listed here, // the block can be dug // // An empty vec implies that all blocks will match repeated string block_group = 1; // If this interaction rule applies while the current item has a durability counter, this // value will be subtracted from the current durability in the *default* handler. // // Custom handlers have to account for this manually (TODO helper) uint32 tool_wear = 2; // If None, not even selectable. oneof dig_behavior { // The tool digs in a single frame, and continues digging as long as the // mouse is held down. In order to avoid event storms, consecutive dig // events for the same coordinate will be suppressed by the client. Empty instant_dig = 11; // The tool digs in a single frame, but the mouse button must be released // and pressed again before the next dig Empty instant_dig_oneshot = 12; // Given in seconds double constant_time = 13; // scaled_time * block's dig_time_multiplier = time double scaled_time = 14; // The tool interacts with the block for raycasting (including interact key, // and replace-upon, blocking raycasts to blocks behind this one), but it can't dig it Empty undiggable = 15; } } // Item and its quantity, whether a stack or a wear message ItemStack { // The short_name of the item in question string item_name = 1; // The quantity; interpretation depends on quantity_type uint32 quantity = 2; uint32 current_wear = 5; // Copy of ItemDef.quantity_type oneof quantity_type { // If set, the item stacks up to N copies. Stacks can be split up. uint32 stack = 11; // If set, the item has wear (from 0 to N) but does not stack. // Note that items don't automatically destroy themselves when wear reaches // zero, unless the item's callback does so explicitly // // Item cannot be split up. uint32 wear = 12; } } message Inventory { // Dimensions for the inventory uint32 height = 1; uint32 width = 2; // Entries in the inventory. An empty slot will have a blank item_name and a zero quantity. // Note that zero quantity on its own does NOT imply empty slot. // Must have cardinality length*width; represented in row-major order repeated ItemStack contents = 3; }