Table of Contents

Class BlockSchematic

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
[JsonObject(MemberSerialization.OptIn)]
public class BlockSchematic
Inheritance
BlockSchematic
Inherited Members

Constructors

BlockSchematic()

public BlockSchematic()

Fields

BlockCodes

[JsonProperty]
public Dictionary<int, AssetLocation> BlockCodes

Field Value

Dictionary<int, AssetLocation>

BlockEntities

[JsonProperty]
public Dictionary<uint, string> BlockEntities

Field Value

Dictionary<uint, string>

BlockEntitiesUnpacked

public Dictionary<BlockPos, string> BlockEntitiesUnpacked

Field Value

Dictionary<BlockPos, string>

BlockIds

[JsonProperty]
public List<int> BlockIds

Field Value

List<int>

BlocksUnpacked

public Dictionary<BlockPos, int> BlocksUnpacked

Field Value

Dictionary<BlockPos, int>

DecorIds

[JsonProperty]
public List<int> DecorIds

Field Value

List<int>

DecorIndices

[JsonProperty]
public List<uint> DecorIndices

Field Value

List<uint>

DecorsUnpacked

public Dictionary<BlockPos, Block[]> DecorsUnpacked

Field Value

Dictionary<BlockPos, Block[]>

Entities

[JsonProperty]
public List<string> Entities

Field Value

List<string>

EntitiesUnpacked

public List<Entity> EntitiesUnpacked

Field Value

List<Entity>

EntranceRotation

[JsonProperty]
public int EntranceRotation

Field Value

int

FluidsLayerUnpacked

public Dictionary<BlockPos, int> FluidsLayerUnpacked

Field Value

Dictionary<BlockPos, int>

GameVersion

[JsonProperty]
public string GameVersion

Field Value

string

Indices

[JsonProperty]
public List<uint> Indices

Field Value

List<uint>

ItemCodes

[JsonProperty]
public Dictionary<int, AssetLocation> ItemCodes

Field Value

Dictionary<int, AssetLocation>

OmitLiquids

public bool OmitLiquids

Field Value

bool

PackedOffset

public FastVec3i PackedOffset

Field Value

FastVec3i

PathwayOffsets

Distance from the bottom left door block, so the bottom left door block is always at 0,0,0

public BlockPos[][] PathwayOffsets

Field Value

BlockPos[][]

PathwaySides

public BlockFacing[] PathwaySides

Field Value

BlockFacing[]

PathwayStarts

Distance positions from bottom left corner of the schematic. Only the first door block.

public BlockPos[] PathwayStarts

Field Value

BlockPos[]

ReplaceMode

[JsonProperty]
public EnumReplaceMode ReplaceMode

Field Value

EnumReplaceMode

SizeX

[JsonProperty]
public int SizeX

Field Value

int

SizeY

[JsonProperty]
public int SizeY

Field Value

int

SizeZ

[JsonProperty]
public int SizeZ

Field Value

int

UndergroundCheckPositions

public BlockPos[] UndergroundCheckPositions

Field Value

BlockPos[]

empty

protected ushort empty

Field Value

ushort

fillerBlock

protected Block fillerBlock

Field Value

Block

pathwayBlock

protected Block pathwayBlock

Field Value

Block

undergroundBlock

protected Block undergroundBlock

Field Value

Block

Properties

BlockRemaps

Set by the RemapperAssistant in OnFinalizeAssets
Heads up!: This is unordered, it will iterate through the different game versions' remaps not necessarily in the order they originally appear in remaps.json config. If any block remaps over the years have duplicate original block names, behavior for those ones may be unpredictable

public static Dictionary<string, Dictionary<string, string>> BlockRemaps { get; set; }

Property Value

Dictionary<string, Dictionary<string, string>>

ItemRemaps

Set by the RemapperAssistant in OnFinalizeAssets

public static Dictionary<string, Dictionary<string, string>> ItemRemaps { get; set; }

Property Value

Dictionary<string, Dictionary<string, string>>

Methods

AddArea(IWorldAccessor, BlockPos, BlockPos)

Adds an area to the schematic.

public virtual void AddArea(IWorldAccessor world, BlockPos start, BlockPos end)

Parameters

world IWorldAccessor

The world the blocks are in

start BlockPos

The start position of all the blocks.

end BlockPos

The end position of all the blocks.

AdjustStartPos(BlockPos, EnumOrigin)

Adjusts the starting position of the schemtic.

public virtual BlockPos AdjustStartPos(BlockPos startpos, EnumOrigin origin)

Parameters

startpos BlockPos
origin EnumOrigin

Returns

BlockPos

ClonePacked()

Makes a deep copy of the packed schematic. Unpacked data and loaded meta information is not cloned.

public virtual BlockSchematic ClonePacked()

Returns

BlockSchematic

DecodeBlockEntityData(string)

Imports the tree data from a string.

public virtual TreeAttribute DecodeBlockEntityData(string data)

Parameters

data string

Returns

TreeAttribute

EncodeBlockEntityData(BlockEntity)

Exports the block entity data to a string.

public virtual string EncodeBlockEntityData(BlockEntity be)

Parameters

be BlockEntity

Returns

string

GetJustPositions(BlockPos)

Gets just the positions of the blocks.

public virtual BlockPos[] GetJustPositions(BlockPos origin)

Parameters

origin BlockPos

The origin point to start from

Returns

BlockPos[]

An array containing the BlockPos of each block in the area.

GetStartPos(BlockPos, EnumOrigin)

Gets the starting position of the schematic.

public virtual BlockPos GetStartPos(BlockPos pos, EnumOrigin origin)

Parameters

pos BlockPos
origin EnumOrigin

Returns

BlockPos

Init(IBlockAccessor)

public virtual void Init(IBlockAccessor blockAccessor)

Parameters

blockAccessor IBlockAccessor

InitMetaBlocks(IBlockAccessor)

public void InitMetaBlocks(IBlockAccessor blockAccessor)

Parameters

blockAccessor IBlockAccessor

LoadFromFile(string, ref string)

Loads the schematic from a file.

public static BlockSchematic LoadFromFile(string infilepath, ref string error)

Parameters

infilepath string
error string

Returns

BlockSchematic

LoadFromString(string, ref string)

Loads a schematic from a string.

public static BlockSchematic LoadFromString(string jsoncode, ref string error)

Parameters

jsoncode string
error string

Returns

BlockSchematic

LoadMetaInformationAndValidate(IBlockAccessor, IWorldAccessor, string)

Loads the meta information for each block in the schematic.

public void LoadMetaInformationAndValidate(IBlockAccessor blockAccessor, IWorldAccessor worldForResolve, string fileNameForLogging)

Parameters

blockAccessor IBlockAccessor
worldForResolve IWorldAccessor
fileNameForLogging string

Pack(IWorldAccessor, BlockPos)

public virtual bool Pack(IWorldAccessor world, BlockPos startPos)

Parameters

world IWorldAccessor
startPos BlockPos

Returns

bool

Place(IBlockAccessor, IWorldAccessor, BlockPos, bool)

Will place all blocks using the configured replace mode. Note: If you use a revertable or bulk block accessor you will have to call PlaceBlockEntities() after the Commit()

public virtual int Place(IBlockAccessor blockAccessor, IWorldAccessor worldForCollectibleResolve, BlockPos startPos, bool replaceMetaBlocks = true)

Parameters

blockAccessor IBlockAccessor
worldForCollectibleResolve IWorldAccessor
startPos BlockPos
replaceMetaBlocks bool

Returns

int

Place(IBlockAccessor, IWorldAccessor, BlockPos, EnumReplaceMode, bool)

Will place all blocks using the supplied replace mode. Note: If you use a revertable or bulk block accessor you will have to call PlaceBlockEntities() after the Commit()

public virtual int Place(IBlockAccessor blockAccessor, IWorldAccessor worldForCollectibleResolve, BlockPos startPos, EnumReplaceMode mode, bool replaceMetaBlocks = true)

Parameters

blockAccessor IBlockAccessor
worldForCollectibleResolve IWorldAccessor
startPos BlockPos
mode EnumReplaceMode
replaceMetaBlocks bool

Returns

int

PlaceDecors(IBlockAccessor, BlockPos)

public virtual void PlaceDecors(IBlockAccessor blockAccessor, BlockPos startPos)

Parameters

blockAccessor IBlockAccessor
startPos BlockPos

PlaceDecors(IBlockAccessor, BlockPos, Rectanglei)

public virtual void PlaceDecors(IBlockAccessor blockAccessor, BlockPos startPos, Rectanglei rect)

Parameters

blockAccessor IBlockAccessor
startPos BlockPos
rect Rectanglei

PlaceEntitiesAndBlockEntities(IBlockAccessor, IWorldAccessor, BlockPos, Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>, bool, Dictionary<int, Dictionary<int, int>>, int, Dictionary<BlockPos, Block>, bool)

Places all the entities and blocks in the schematic at the position.

public void PlaceEntitiesAndBlockEntities(IBlockAccessor blockAccessor, IWorldAccessor worldForCollectibleResolve, BlockPos startPos, Dictionary<int, AssetLocation> blockCodes, Dictionary<int, AssetLocation> itemCodes, bool replaceBlockEntities = false, Dictionary<int, Dictionary<int, int>> replaceBlocks = null, int centerrockblockid = 0, Dictionary<BlockPos, Block> layerBlockForBlockEntities = null, bool resolveImports = true)

Parameters

blockAccessor IBlockAccessor
worldForCollectibleResolve IWorldAccessor
startPos BlockPos
blockCodes Dictionary<int, AssetLocation>
itemCodes Dictionary<int, AssetLocation>
replaceBlockEntities bool
replaceBlocks Dictionary<int, Dictionary<int, int>>
centerrockblockid int
layerBlockForBlockEntities Dictionary<BlockPos, Block>
resolveImports bool

Turn it off to spawn structures as they are. For example, in this mode, instead of traders, their meta spawners will spawn

PlaceReplaceAll(IBlockAccessor, BlockPos, Block, bool)

protected virtual int PlaceReplaceAll(IBlockAccessor blockAccessor, BlockPos pos, Block newBlock, bool replaceMeta)

Parameters

blockAccessor IBlockAccessor
pos BlockPos
newBlock Block
replaceMeta bool

Returns

int

PlaceReplaceAllNoAir(IBlockAccessor, BlockPos, Block, bool)

protected virtual int PlaceReplaceAllNoAir(IBlockAccessor blockAccessor, BlockPos pos, Block newBlock, bool replaceMeta)

Parameters

blockAccessor IBlockAccessor
pos BlockPos
newBlock Block
replaceMeta bool

Returns

int

PlaceReplaceOnlyAir(IBlockAccessor, BlockPos, Block, bool)

protected virtual int PlaceReplaceOnlyAir(IBlockAccessor blockAccessor, BlockPos pos, Block newBlock, bool replaceMeta)

Parameters

blockAccessor IBlockAccessor
pos BlockPos
newBlock Block
replaceMeta bool

Returns

int

PlaceReplaceable(IBlockAccessor, BlockPos, Block, bool)

protected virtual int PlaceReplaceable(IBlockAccessor blockAccessor, BlockPos pos, Block newBlock, bool replaceMeta)

Parameters

blockAccessor IBlockAccessor
pos BlockPos
newBlock Block
replaceMeta bool

Returns

int

Save(string)

Saves a schematic to a file.

public virtual string Save(string outfilepath)

Parameters

outfilepath string

Returns

string

StringEncodeTreeAttribute(ITreeAttribute)

Exports the tree attribute data to a string.

public virtual string StringEncodeTreeAttribute(ITreeAttribute tree)

Parameters

tree ITreeAttribute

Returns

string

ToJson()

public virtual string ToJson()

Returns

string

TransformWhilePacked(IWorldAccessor, EnumOrigin, int, EnumAxis?)

Attempts to transform each block as they are placed in directions different from the schematic.

public virtual void TransformWhilePacked(IWorldAccessor worldForResolve, EnumOrigin aroundOrigin, int angle, EnumAxis? flipAxis = null)

Parameters

worldForResolve IWorldAccessor
aroundOrigin EnumOrigin
angle int
flipAxis EnumAxis?