Skip to content

Go: World

Functions

ScanRegion

Go
func ScanRegion(dim, x1, y1, z1, x2, y2, z2 int32) ([]BlockInfo, []EntityInfo, error)

ScanRegion reads every block and entity in a box. Server thread only.

  • Parameters:
    • dim : int32
    • x1 : int32
    • y1 : int32
    • z1 : int32
    • x2 : int32
    • y2 : int32
    • z2 : int32
  • Return type: ([]BlockInfo, []EntityInfo, error)
  • Slots: scan_region

ScanRegionIndexed

Go
func ScanRegionIndexed(dim, x1, y1, z1, x2, y2, z2 int32) ([]PaletteEntry, []BlockCell, error)

ScanRegionIndexed reads a box as a palette of distinct block states and the cells that index it, which is far smaller than ScanRegion for a large box. Server thread only.

  • Parameters:
    • dim : int32
    • x1 : int32
    • y1 : int32
    • z1 : int32
    • x2 : int32
    • y2 : int32
    • z2 : int32
  • Return type: ([]PaletteEntry, []BlockCell, error)
  • Slots: scan_region_indexed

GetBlock

Go
func GetBlock(dim, x, y, z int32) (BlockInfo, error)

GetBlock reads the block at a cell. Server thread only.

  • Parameters:
    • dim : int32
    • x : int32
    • y : int32
    • z : int32
  • Return type: (BlockInfo, error)
  • Slots: get_block

Seed

Go
func Seed() (int64, error)

Seed is the level seed.

  • Return type: (int64, error)
  • Slots: get_seed

Difficulty

Go
func Difficulty() (int32, error)

Difficulty is the level difficulty, 0 peaceful to 3 hard.

SetDifficulty

Go
func SetDifficulty(d int32) error

SetDifficulty sets the level difficulty.

GameRule

Go
func GameRule(name string) (string, error)

GameRule reads a game rule as text.

  • Parameters:
    • name : string
  • Return type: (string, error)
  • Slots: game_rule_get

SetGameRule

Go
func SetGameRule(name, value string) error

SetGameRule writes a game rule from text.

  • Parameters:
    • name : string
    • value : string
  • Return type: error
  • Slots: game_rule_set

Time

Go
func Time() (int64, error)

Time is the time of day in ticks.

  • Return type: (int64, error)
  • Slots: get_time

SetTime

Go
func SetTime(t int64) error

SetTime sets the time of day in ticks.

  • Parameters:
    • t : int64
  • Return type: error
  • Slots: set_time

SetWeather

Go
func SetWeather(weather int32) error

SetWeather sets the weather: 0 clear, 1 rain, 2 thunder.

  • Parameters:
    • weather : int32
  • Return type: error
  • Slots: set_weather

SaveLevel

Go
func SaveLevel() error

SaveLevel saves the level now.

SpawnParticle

Go
func SpawnParticle(dim int32, effect string, x, y, z float64) error

SpawnParticle shows a particle effect to everyone near it.

  • Parameters:
    • dim : int32
    • effect : string
    • x : float64
    • y : float64
    • z : float64
  • Return type: error
  • Slots: spawn_particle

Explode

Go
func Explode(dim int32, x, y, z float64, radius float32, o ExplodeOptions) error

Explode makes an explosion of the given radius.

  • Parameters:
    • dim : int32
    • x : float64
    • y : float64
    • z : float64
    • radius : float32
    • o : ExplodeOptions
  • Return type: error
  • Slots: explode

DefaultSpawn

Go
func DefaultSpawn() (x, y, z int32, err error)

DefaultSpawn is the level's world spawn.

SetDefaultSpawn

Go
func SetDefaultSpawn(x, y, z int32) error

SetDefaultSpawn moves the level's world spawn.

SetBiome

Go
func SetBiome(dim, minX, minZ, maxX, maxZ int32, biome string) (int32, error)

SetBiome sets the biome of every column in a rectangle and returns how many changed.

  • Parameters:
    • dim : int32
    • minX : int32
    • minZ : int32
    • maxX : int32
    • maxZ : int32
    • biome : string
  • Return type: (int32, error)
  • Slots: level_set_biome

FindPath

Go
func FindPath(who Entity, x, y, z int32) (*Nbt, error)

FindPath computes a path for an actor to a target cell, as the host's SNBT. Every current host answers not provided.

  • Parameters:
    • who : Entity
    • x : int32
    • y : int32
    • z : int32
  • Return type: (*Nbt, error)
  • Slots: level_find_path

UpdateWeather

Go
func UpdateWeather(rainLevel float32, rainTicks int32, lightningLevel float32, lightningTicks int32) error

UpdateWeather sets the level and the remaining ticks of rain and of lightning.

  • Parameters:
    • rainLevel : float32
    • rainTicks : int32
    • lightningLevel : float32
    • lightningTicks : int32
  • Return type: error
  • Slots: level_update_weather

LevelSleepStatus

Go
func LevelSleepStatus() (SleepStatus, error)

LevelSleepStatus reads the sleep status of the players.

Villages

Go
func Villages(dim int32) ([]Village, error)

Villages lists the villages of one dimension.

  • Parameters:
    • dim : int32
  • Return type: ([]Village, error)
  • Slots: villages

StructuresNear

Go
func StructuresNear(dim, x, y, z, radius int32) ([]Structure, error)

StructuresNear lists the hardcoded generation areas of the loaded chunks within a radius.

  • Parameters:
    • dim : int32
    • x : int32
    • y : int32
    • z : int32
    • radius : int32
  • Return type: ([]Structure, error)
  • Slots: structures_near

ChunksLoaded

Go
func ChunksLoaded(dim, minX, minZ, maxX, maxZ int32) (bool, error)

ChunksLoaded reports whether every chunk covered by the region is in memory.

  • Parameters:
    • dim : int32
    • minX : int32
    • minZ : int32
    • maxX : int32
    • maxZ : int32
  • Return type: (bool, error)
  • Slots: level_chunks_loaded

DeleteChunkKeys

Go
func DeleteChunkKeys(dim, chunkX, chunkZ int32) (int32, error)

DeleteChunkKeys deletes every save key of a chunk, so the engine regenerates it from the generator on its next load, and returns how many keys went. Only an unloaded chunk can be restored this way.

ChunkKeys

Go
func ChunkKeys(dim, chunkX, chunkZ int32) ([]string, error)

ChunkKeys lists every save key of a chunk. A key is binary, and a Go string holds it as it is.

  • Parameters:
    • dim : int32
    • chunkX : int32
    • chunkZ : int32
  • Return type: ([]string, error)
  • Slots: level_chunk_keys

DeleteSaveKey

Go
func DeleteSaveKey(key string) error

DeleteSaveKey deletes one save key byte for byte. The content is not interpreted.

WorldWeather

Go
func WorldWeather(dim, prop int32) (float64, error)

WorldWeather reads one PIER_WPROP_* value of dimension dim. The error covers an unknown key, a dimension that does not exist and a level that is not ready.

  • Parameters:
    • dim : int32
    • prop : int32
  • Return type: (float64, error)

WorldRainLevel

Go
func WorldRainLevel(dim int32) (float64, error)

WorldRainLevel is the rain level of a dimension, 0 for none to 1 for full rain.

  • Parameters:
    • dim : int32
  • Return type: (float64, error)

WorldTargetRainLevel

Go
func WorldTargetRainLevel(dim int32) (float64, error)

WorldTargetRainLevel reads PIER_WPROP_TARGET_RAIN_LEVEL of dimension dim.

  • Parameters:
    • dim : int32
  • Return type: (float64, error)

WorldLightningLevel

Go
func WorldLightningLevel(dim int32) (float64, error)

WorldLightningLevel is the lightning level of a dimension, 0 for none to 1 for a storm.

  • Parameters:
    • dim : int32
  • Return type: (float64, error)

WorldTargetLightningLevel

Go
func WorldTargetLightningLevel(dim int32) (float64, error)

WorldTargetLightningLevel reads PIER_WPROP_TARGET_LIGHTNING_LEVEL of dimension dim.

  • Parameters:
    • dim : int32
  • Return type: (float64, error)

WorldFogLevel

Go
func WorldFogLevel(dim int32) (float64, error)

WorldFogLevel reads PIER_WPROP_FOG_LEVEL of dimension dim.

  • Parameters:
    • dim : int32
  • Return type: (float64, error)

WorldSkyFlashTime

Go
func WorldSkyFlashTime(dim int32) (float64, error)

WorldSkyFlashTime reads PIER_WPROP_SKY_FLASH_TIME of dimension dim.

  • Parameters:
    • dim : int32
  • Return type: (float64, error)

EntityInfo

Go
1
2
3
4
5
type EntityInfo struct {
    X, Y, Z int32
    Type    string
    SNBT    string
}

EntityInfo is one entity a region scan found: the cell holding it, its type and its SNBT.

PaletteEntry

Go
1
2
3
4
5
type PaletteEntry struct {
    Index uint32
    Name  string
    SNBT  string
}

PaletteEntry is one distinct block state of an indexed scan.

BlockCell

Go
1
2
3
4
type BlockCell struct {
    X, Y, Z int32
    Index   uint32
}

BlockCell is one cell and an index into a palette, for ScanRegionIndexed and SetBlocks.

ExplodeOptions

Go
1
2
3
4
5
6
7
type ExplodeOptions struct {
    MaxResistance   float32
    Source          ActorID
    Fire            bool
    BreaksBlocks    bool
    AllowUnderwater bool
}

ExplodeOptions are the optional parts of an explosion.

SleepStatus

Go
1
2
3
4
5
type SleepStatus struct {
    Sleeping       bool
    TotalPlayers   int32
    ActiveSleeping int32
}

SleepStatus is how many players sleep.

Village

Go
1
2
3
4
5
6
type Village struct {
    UUID     string
    Center   [3]int32
    Min, Max [3]int32
    PoiCount int32
}

Village is one village.

Structure

Go
1
2
3
4
type Structure struct {
    Kind     string
    Min, Max [3]int32
}

Structure is one hardcoded generation area: a stronghold, a witch hut, an ocean monument or a similar structure.