Class BlockEntityBehavior
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Basic class for block entities - a data structures to hold custom information for blocks, e.g. for chests to hold it's contents Open in GitHub
public abstract class BlockEntityBehavior
- Inheritance
-
BlockEntityBehavior
- Inherited Members
- Extension Methods
Constructors
BlockEntityBehavior(BlockEntity)
public BlockEntityBehavior(BlockEntity blockentity)
Parameters
blockentityBlockEntity
Fields
Api
public ICoreAPI Api
Field Value
Blockentity
The block for this behavior instance.
public BlockEntity Blockentity
Field Value
properties
The properties of this block behavior.
public JsonObject? properties
Field Value
Properties
Block
Alias of BlockEntity.Block
public Block Block { get; }
Property Value
Pos
Alias of Blockentity.Pos
public BlockPos Pos { get; }
Property Value
Methods
FromTreeAttributes(ITreeAttribute, IWorldAccessor)
public virtual void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve)
Parameters
treeITreeAttributeworldAccessForResolveIWorldAccessor
GetBlockInfo(IPlayer, StringBuilder)
public virtual void GetBlockInfo(IPlayer forPlayer, StringBuilder dsc)
Parameters
forPlayerIPlayerdscStringBuilder
Initialize(ICoreAPI, JsonObject)
Called right after the block behavior was created
public virtual void Initialize(ICoreAPI api, JsonObject properties)
Parameters
apiICoreAPIpropertiesJsonObject
OnBlockBroken(IPlayer?)
public virtual void OnBlockBroken(IPlayer? byPlayer = null)
Parameters
byPlayerIPlayer
OnBlockPlaced(ItemStack?)
public virtual void OnBlockPlaced(ItemStack? byItemStack = null)
Parameters
byItemStackItemStack
OnBlockRemoved()
public virtual void OnBlockRemoved()
OnBlockUnloaded()
public virtual void OnBlockUnloaded()
OnLoadCollectibleMappings(IWorldAccessor, Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>, int)
[Obsolete("Use the variant with resolveImports parameter")]
public virtual void OnLoadCollectibleMappings(IWorldAccessor worldForNewMappings, Dictionary<int, AssetLocation> oldBlockIdMapping, Dictionary<int, AssetLocation> oldItemIdMapping, int schematicSeed)
Parameters
worldForNewMappingsIWorldAccessoroldBlockIdMappingDictionary<int, AssetLocation>oldItemIdMappingDictionary<int, AssetLocation>schematicSeedint
OnLoadCollectibleMappings(IWorldAccessor, Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>, int, bool)
public virtual void OnLoadCollectibleMappings(IWorldAccessor worldForNewMappings, Dictionary<int, AssetLocation> oldBlockIdMapping, Dictionary<int, AssetLocation> oldItemIdMapping, int schematicSeed, bool resolveImports)
Parameters
worldForNewMappingsIWorldAccessoroldBlockIdMappingDictionary<int, AssetLocation>oldItemIdMappingDictionary<int, AssetLocation>schematicSeedintresolveImportsbool
OnPlacementBySchematic(ICoreServerAPI, IBlockAccessor, BlockPos, Dictionary<int, Dictionary<int, int>>, int, Block, bool)
public virtual void OnPlacementBySchematic(ICoreServerAPI api, IBlockAccessor blockAccessor, BlockPos pos, Dictionary<int, Dictionary<int, int>> replaceBlocks, int centerrockblockid, Block layerBlock, bool resolveImports)
Parameters
apiICoreServerAPIblockAccessorIBlockAccessorposBlockPosreplaceBlocksDictionary<int, Dictionary<int, int>>centerrockblockidintlayerBlockBlockresolveImportsbool
OnReceivedClientPacket(IPlayer, int, byte[])
public virtual void OnReceivedClientPacket(IPlayer fromPlayer, int packetid, byte[] data)
Parameters
OnReceivedServerPacket(int, byte[])
public virtual void OnReceivedServerPacket(int packetid, byte[] data)
Parameters
OnStoreCollectibleMappings(Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>)
public virtual void OnStoreCollectibleMappings(Dictionary<int, AssetLocation> blockIdMapping, Dictionary<int, AssetLocation> itemIdMapping)
Parameters
blockIdMappingDictionary<int, AssetLocation>itemIdMappingDictionary<int, AssetLocation>
OnTesselation(ITerrainMeshPool, ITesselatorAPI)
Let's you add your own meshes to a chunk. Don't reuse the meshdata instance anywhere in your code. Return true to skip the default mesh. WARNING! The Tesselator runs in a seperate thread, so you have to make sure the fields and methods you access inside this method are thread safe.
public virtual bool OnTesselation(ITerrainMeshPool mesher, ITesselatorAPI tessThreadTesselator)
Parameters
mesherITerrainMeshPoolThe chunk mesh, add your stuff here
tessThreadTesselatorITesselatorAPIIf you need to tesselate something, you should use this tesselator, since using the main thread tesselator can cause race conditions and crash the game
Returns
- bool
True to skip default mesh, false to also add the default mesh
ToTreeAttributes(ITreeAttribute)
public virtual void ToTreeAttributes(ITreeAttribute tree)
Parameters
treeITreeAttribute