Table of Contents

Class BlockSchematic

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

Constructors

BlockSchematic()

public BlockSchematic()

BlockSchematic(IServerWorldAccessor, IBlockAccessor, BlockPos, BlockPos, bool)

public BlockSchematic(IServerWorldAccessor world, IBlockAccessor blockAccess, BlockPos start, BlockPos end, bool notLiquids)

Parameters

world IServerWorldAccessor
blockAccess IBlockAccessor
start BlockPos
end BlockPos
notLiquids bool

BlockSchematic(IServerWorldAccessor, BlockPos, BlockPos, bool)

Construct a schematic from a specified area in the specified world

public BlockSchematic(IServerWorldAccessor world, BlockPos start, BlockPos end, bool notLiquids)

Parameters

world IServerWorldAccessor
start BlockPos
end BlockPos
notLiquids bool

Fields

AbovegroundBlockId

public static int AbovegroundBlockId

Field Value

int

AbovegroundCheckPositions

public BlockPos[] AbovegroundCheckPositions

Field Value

BlockPos[]

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<long> DecorIds

Field Value

List<long>

DecorIndices

[JsonProperty]
public List<uint> DecorIndices

Field Value

List<uint>

DecorsUnpacked

public Dictionary<BlockPos, Dictionary<int, Block>> DecorsUnpacked

Field Value

Dictionary<BlockPos, Dictionary<int, 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

FillerBlockId

public static int FillerBlockId

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

OriginalPos

[JsonProperty]
public BlockPos OriginalPos

Field Value

BlockPos

PackedOffset

public FastVec3i PackedOffset

Field Value

FastVec3i

PathwayBlockId

public static int PathwayBlockId

Field Value

int

PathwayBlocksUnpacked

public List<BlockPosFacing> PathwayBlocksUnpacked

Field Value

List<BlockPosFacing>

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[]

PosBitMask

This bitmask for the position in schematics

public const uint PosBitMask = 1023

Field Value

uint

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

UndergroundBlockId

public static int UndergroundBlockId

Field Value

int

UndergroundCheckPositions

public BlockPos[] UndergroundCheckPositions

Field Value

BlockPos[]

empty

protected ushort empty

Field Value

ushort

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, IBlockAccessor, BlockPos, BlockPos)

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

Parameters

world IWorldAccessor
blockAccess IBlockAccessor
start BlockPos
end BlockPos

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.

GetRotatedPos(EnumOrigin, int, int, int, int)

public BlockPos GetRotatedPos(EnumOrigin aroundOrigin, int angle, int dx, int dy, int dz)

Parameters

aroundOrigin EnumOrigin
angle int
dx int
dy int
dz int

Returns

BlockPos

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

IsFillerOrPath(Block)

public bool IsFillerOrPath(Block newBlock)

Parameters

newBlock Block

Returns

bool

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

PasteToMiniDimension(ICoreServerAPI, IBlockAccessor, IMiniDimension, BlockPos, bool)

public void PasteToMiniDimension(ICoreServerAPI sapi, IBlockAccessor blockAccess, IMiniDimension miniDimension, BlockPos originPos, bool replaceMetaBlocks)

Parameters

sapi ICoreServerAPI
blockAccess IBlockAccessor
miniDimension IMiniDimension
originPos BlockPos
replaceMetaBlocks 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?, bool)

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, bool isDungeon = false)

Parameters

worldForResolve IWorldAccessor
aroundOrigin EnumOrigin
angle int
flipAxis EnumAxis?
isDungeon bool