blocks – Block descriptions

The blocks module contains descriptions of blocks.

class bravo.blocks.Block(slot, name, secondary=0, drop=None, replace=0, ratio=1, quantity=1, dim=16, breakable=True, orientation=None)[source]

Bases: object

A model for a block.

There are lots of rule and properties specific to different types of blocks. This class encapsulates those properties in a singleton-style interface, allowing many blocks to be referenced in one location.

The basic idea of this class is to provide some centralized data and information about blocks, in order to abstract away as many special cases as possible. In general, if several blocks all have some special behavior, then it may be worthwhile to store data describing that behavior on this class rather than special-casing it in multiple places.

Parameters:
  • slot (int) – The index of this block. Must be globally unique.
  • name (str) – A common name for this block.
  • secondary (int) – The metadata/damage/secondary attribute for this block. Defaults to zero.
  • drop (int) – The type of block that should be dropped when an instance of this block is destroyed. Defaults to the slot value, to drop instances of this same type of block. To indicate that this block does not drop anything, set to air.
  • replace (int) – The type of block to place in the map when instances of this block are destroyed. Defaults to air.
  • ratio (float) – The probability of this block dropping a block on destruction.
  • quantity (int) – The number of blocks dropped when this block is destroyed.
  • dim (int) – How much light dims when passing through this kind of block. Defaults to 16 = opaque block.
  • breakable (bool) – Whether this block is diggable, breakable, bombable, explodeable, etc. Only a few blocks actually genuinely cannot be broken, so the default is True.
  • orientation (tuple) – The orientation data for a block. See orientable() for an explanation. The data should be in standard face order.
orientable()[source]

Whether this block can be oriented.

Orientable blocks are positioned according to the face on which they are built. They may not be buildable on all faces. Blocks are only orientable if their metadata can be used to directly and uniquely determine the face against which they were built.

Ladders are orientable, signposts are not.

Return type:bool
Returns:True if this block can be oriented, False if not.
orientation(face)[source]

Retrieve the metadata for a certain orientation, or None if this block cannot be built against the given face.

This method only returns valid data for orientable blocks; check orientable() first.

class bravo.blocks.Item(slot, name, secondary=0)[source]

Bases: object

An item.

bravo.blocks.armor_boots

List of slots of boots.

bravo.blocks.armor_chestplates

List of slots of chestplates.

Note that slot 303 (chainmail chestplate) is a chestplate, even though it is not normally obtainable.

bravo.blocks.armor_helmets

List of slots of helmets.

Note that slot 86 (pumpkin) is a helmet.

bravo.blocks.armor_leggings

List of slots of leggings.

bravo.blocks.blocks

A dictionary of Block objects.

This dictionary can be indexed by slot number or block name.

bravo.blocks.items

A dictionary of Item objects.

This dictionary can be indexed by slot number or block name.

bravo.blocks.parse_block(block)[source]

Get the key for a given block/item.

Project Versions

Previous topic

Core

Next topic

chunk – Chunk data structures

This Page