// 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 cuberef.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 cuberef.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; // 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. repeated string block_group = 1; // 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; } } // 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; // If stackable, the max stack size. Note that this is a property of the item stack, // not the item itself - if the item definition changes after the stack is created, // old stacks will carry the old stacking behavior. uint32 max_stack = 3; // TODO future expansion: extended data, in a way that prevents client tampering } message Inventory { // Unique ID for this inventory. Assigned by the server; no guaranteed structure bytes inventory_key = 1; // Dimensions for the inventory uint32 height = 2; uint32 width = 3; // 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 = 4; }