Перейти к основному содержанию

GenerationUtils

Module used to simplify generation tasks in mods logic.

Index

Interfaces

IMinableParams

IMinableParams:

data

data: number

Ore block data.

id

id: number

Ore block numeric identifier.

optionalnoStoneCheck

noStoneCheck?: number

If true, no check for stone is performed so the ore may be generated in the air. Use this to debug ore generation in the superflat worlds.

MinableAmountParams

MinableAmountParams:

amount

amount: number

Amount of the ore to be generated, minimum allowed value is 1. Use at least 6 to be able to find generated ore vein. Note that amount doesn't mean blocks count, it is just an input value for generation algorithm.

data

data: number

Ore block data.

id

id: number

Ore block numeric identifier.

optionalnoStoneCheck

noStoneCheck?: number

If true, no check for stone is performed so the ore may be generated in the air. Use this to debug ore generation in the superflat worlds.

MinableSizeParams

MinableSizeParams:

data

data: number

Ore block data.

id

id: number

Ore block numeric identifier.

optionalnoStoneCheck

noStoneCheck?: number

If true, no check for stone is performed so the ore may be generated in the air. Use this to debug ore generation in the superflat worlds.

optionalratio

ratio?: number = 1

Amount ratio of ore vein per generation chunk.

size

size: number

Used to calculate amount, using simple formula size * ratio * 3. Minimum allowed value of amount is 1.

Type Aliases

MinableParams

Functions

canSeeSky

  • canSeeSky(x: number, y: number, z: number): boolean

  • Parameters

    • x: number
    • y: number
    • z: number

    Returns boolean

    true, if one can see sky from the specified position, false otherwise.

findHighSurface

  • findHighSurface(x: number, z: number): Vector
  • Finds limited to y=128 coordinate empty space on the specified x and z coordinates.


    Parameters

    • x: number
    • z: number

    Returns Vector

findLowSurface

  • findLowSurface(x: number, z: number): Vector
  • Finds limited to y=64 coordinate empty space on the specified x and z coordinates.


    Parameters

    • x: number
    • z: number

    Returns Vector

findSurface

  • findSurface(x: number, y: number, z: number): Vector
  • Finds limited to the specified y coordinate empty space on the specified x and z coordinates.


    Parameters

    • x: number
    • y: number
    • z: number

    Returns Vector

genMinable

  • genMinable(x: number, y: number, z: number, params: MinableParams): void
  • Generates ore vein on the specified coordinates using specified params.


    Parameters

    • x: number
    • y: number
    • z: number
    • params: MinableParams

      vein generation params

    Returns void

generateOre

  • generateOre(x: number, y: number, z: number, id: number, data: number, amount: number, noStoneCheck: boolean): void
  • Generates ore vein on the specified coordinates.


    Parameters

    • x: number
    • y: number
    • z: number
    • id: number

      ore block ID

    • data: number

      ore block data

    • amount: number

      ore amount, use at least 6 to be able to find generated ore vein; note that amount doesn't mean blocks count, it is just an input value for generation algorithm

    • noStoneCheck: boolean

      if true, no check for stone is performed so the ore may be generated in the air; use this to debug ore generation in the superflat worlds

    Returns void

generateOreCustom

  • generateOreCustom(x: number, y: number, z: number, id: number, data: number, amount: number, whitelist: boolean, listOfIds: number[]): void
  • Generates ore vein on the specified coordinates with custom whitelist/blacklist.

    @since

    2.0.1b17


    Parameters

    • x: number
    • y: number
    • z: number
    • id: number

      ore block ID

    • data: number

      ore block data

    • amount: number

      ore amount, use at least 6 to be able to find generated ore vein; note that amount doesn't mean blocks count, it is just an input value for generation algorithm

    • whitelist: boolean

      if true, specified block IDs are used as whitelist for generation (only the IDs from the list can be replaced with ores); if false, specified block IDs are used as a blacklist (only the IDs from the list canNOT be replaced with ores)

    • listOfIds: number[]

      array of block IDs to be used as whitelist or blacklist

    Returns void

getPerlinNoise

  • getPerlinNoise(x: number, y: number, z: number, seed?: number, scale?: number, numOctaves?: number): number
  • Retrieves perlin noise value at the specified coordinates.

    @since

    2.0.1b11


    Parameters

    • x: number
    • y: number
    • z: number
    • optionalseed: number

      integer random generator seed. If not specified or set to 0, the default constant value is used

    • optionalscale: number

      noise size, to set the main octave size, use 1 / octave size

    • optionalnumOctaves: number

      number of octaves, the more octaves you use, the more detailed is the generated noise. The next octave is two times smaller then the previous one

    Returns number

isTerrainBlock

  • isTerrainBlock(id: number): boolean

  • Parameters

    • id: number

      numeric tile ID

    Returns boolean

    true if block is solid and light blocking block, false otherwise.

isTransparentBlock

  • isTransparentBlock(id: number): boolean

  • Parameters

    • id: number

      numeric tile ID

    Returns boolean

    true if block is transparent, false otherwise.

randomCoords

  • randomCoords(cx: number, cz: number, lowest?: number, highest?: number): Vector
  • Generates random coordinates inside specified chunk.


    Parameters

    • cx: number

      chunk x coordinate

    • cz: number

      chunk z coordinate

    • optionallowest: number

      lowest possible y coordinate; default is 0

    • optionalhighest: number

      highest possible y coordinate; default is 128

    Returns Vector

randomXZ

  • randomXZ(cx: number, cz: number): { x: number; z: number }
  • Generates random x and z coordinates inside specified chunk.


    Parameters

    • cx: number

      chunk x coordinate

    • cz: number

      chunk z coordinate

    Returns { x: number; z: number }

    • x: number
    • z: number