Modding:Collectible Behavior GroundStorable

From Vintage Story Wiki
Revision as of 05:03, 28 July 2024 by Bluelightning32 (talk | contribs) (→‎Properties: formatting typo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Purpose

This behavior allows the block/item to be stored in groundstorage blocks. A groundstorage block is like a chest with invisible walls, in the sense that it renders its contents. It has no GUI and clicking it directly places or picks up items. The groundstorage block only exists as a placed block; there is no way for the player to end up with one in their inventory (aside from the /giveblock command).

When the player tries to right click a ground storable item or block on the ground, then the behavior tries to add the item to the groundstorage block. If the groundstorage block does not exist yet at that location, then the behavior will try to create it before adding the block/item to it.

Used by blocks

  • agedfirewood
  • axe
  • backpack
  • basket
  • beeswax
  • blade
  • bone
  • book
  • boss
  • bow
  • bowl
  • bowl-meal
  • bugnet
  • burnedbrick
  • chisel
  • clayplanter
  • claypot
  • cleaver
  • cloth
  • clothes
  • club
  • clutter
  • crock
  • crucible
  • crystalizedore
  • dirtyclaypot
  • egg
  • fat
  • feather
  • firestarter
  • firewood
  • flaxfibers
  • flowerpot
  • gem
  • hammer
  • helvehammerhead
  • hide
  • hoe
  • hoop
  • hunterbackpack
  • ingot
  • ingotmold
  • inkandquill
  • jonasframes
  • jonasparts
  • jug
  • knife
  • largegear
  • linensack
  • lore
  • metal
  • metalbit
  • metalnailsandstrips
  • metalplate
  • miningbag
  • nightvisionupgrades
  • nugget
  • oar
  • ore
  • paper
  • pickaxe
  • pineapple
  • plank
  • plumbandsquare
  • powder
  • prospectingpick
  • pumpkin
  • quiver
  • rawbrick
  • refractorybrick
  • resin
  • returnbase
  • returndeath
  • rope
  • rot
  • sail
  • saw
  • schematic
  • scythe
  • sewingkit
  • shears
  • shield
  • shingle
  • shovel
  • sieve
  • solderbar
  • solderingiron
  • spear
  • stick
  • stonebrick
  • storagevessel
  • textureflipper
  • tongs
  • toolmold
  • tuningcylinder
  • wateringcan
  • wrench

Usage

Add it to the to the behaviors, field and set the GroundStorageProperties. The first item to create the groundstorage block at a location will copy its GroundStorageProperties into the block entity at that location. Different kinds of items can be placed in the same ground storage block, if their layouts match, and they are added to different inventory slots. For example, a flax fiber, piece of fat, and stick can all be placed into the same ground storage block, because they all have the Quadrants layout. However, an ingot mold cannot be placed into the same groundstorage as a stick, because the ingot mold has the Halves layout.

Example:

  behaviors: [{
      name: "GroundStorable",
      properties: {
        layout: 'WallHalves',
        wallOffY: 2,
        sprintKey: true,
        selectionBox: { x1: 0, y1: 0, z1: 0, x2: 1, y2: 0.1, z2: 1 },
        collisionBox: { x1: 0, y1: 0, z1: 0, x2: 0, y2: 0, z2: 0 },
      },
  }]

Properties

Layout: (EnumGroundStorageLayout, default: SingleCenter)
SingleCenter
1 inventory slot, with stack size 1. If the layout is set to Quadrants, then it will be implicitly overridden to SingleCenter if the player places the first item in the center.
Halves
1 inventory slots, each with stack size 1.
Quadrants
4 inventory slots, each with stack size 1.
Stacking
1 inventory slot, with up to StackingCapacity stack size. Placing another item on the pile adds it to the item stack in the inventory. So all items in the pile must be mergable into a single item stack. If the pile already has StackingCapacity number of items in it, then the pile will try to grow to the block above by creating a new ground storage block above it.
WallHalves
2 inventory slots, each with stack size 1. This is usually used for tools to show that they are leaned against a wall. The block to the side of the ground storage must accept attachments (be placed against a wall) for the ground storage to accept the item.
WallOffY: (int, default: 1, Recommended minimum: 1)
For the WallHalves layout, this is the height of the ground storage block. Specifically, the walls are checked for support this many blocks up from the base of the ground storage. Tall tools, such as the spear, set this to 2.
PlaceRemoveSound: (asset, default: "sounds/player/build")
This sound is played whenever an item is added or removed from the storage.
RandomizeSoundPitch: (bool, unused)
TessQuantityElements: (int, deprecated)
This is now an alias to ModelItemsToStackSizeRatio
SprintKey: (bool, default: false)
If true, then the sprint key must be held to interact with the groundstorage block. The game uses this on most tools to prevent the tool from accidentally getting placed against a wall when the player really wanted to break the wall.
CollisionBox: (Cuboidf, default: first collision box of the block that created the storageblock, otherwise {x1: 0, y1: 0, z1: 0, x2:1, y2:0.25f, z2:1})
The collision box for the groundstorage block. Notably, this sets the height of the block.
SelectionBox: (Cuboidf, default: CollisionBox value)
The selection box for the groundstorage block. The collision box controls where the player cannot stand, and the selection box controls the size of the black outline when the player points at the block.

Stacking layout only properties

ModelItemsToStackSizeRatio: (float, default: 1)
The StackingModel should be the model of a full stack. This controls the number of cuboids to render from the StackingModel, in case the pile is not full yet. Specifically pile size * ModelItemsToStackSizeRatio elements are rendered. For example, the firewood pile model has one cuboid for each log. It sets the ModelItemsToStackSizeRatio to 0.5 so that every 2 firewood items show a single cuboid (shows fewer cuboids than there are actual items). Another example is the shingle, which sets ModelItemsToStackSizeRatio to 0.5, so that two cuboids are shown for every shingle in the pile. This is because the shingle shape is more complicated in that each shingle uses two cuboids in the model file (has kind of a shovel shape).
StackingTextures: (asset dictionary, default: empty)
A dictionary of texture overrides for the stacking model, similar to the textures dictionary for blocks. For example, the ingots use this so that the same ingot pile shape is used for all types of metal ingots, then each type of metal overrides the texture.
TransferQuantity: (int, default: 1)
The number of items to try to place or take when right click is pressed without the sprint key.
BulkTransferQuantity: (int, default: 4)
The number of items to try to place or take when right click is pressed with the sprint key.
UpSolid: (bool, default: false)
When true, the up face of a full stack is considered solid, such that it can be the parent block for an attachment. For example, the firewood item sets this to true but shingles leave it as false. So torches can be placed on top of a full firewood stack, but not a full shingle stack.
CbScaleYByLayer: (float, default: 0)
If this is non-zero, then the height of the collision and selection boxes are scaled based on the number of items in the pile. This should be set to 1/items per layer. For example, the ingot sets this to 0.125 (which is 1/8). So the number of ingots in the pile is divided by 8, rounded up to the next integer, then the collision and selection box heights are multiplied by this. So a pile with 9 ingots is twice as high as a pile with 2 ingots.
MaxFireable: (int, default: 9999)
If the pile is larger than this value, then it will disallow placing dry grass to convert the pile into a pit kiln.
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository