LevelAccessor

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.world.LevelAccessor;

Implements

LevelAccessor implements the following interfaces:

CommonLevelAccessor,LevelReader,LevelSimulatedRW,BlockAndTintGetter,BlockGetter,LevelWriter

Undocumented Interfaces

LevelTimeAccess,EntityGetter,CollisionGetter,SignalGetter,NoiseBiomeSource,IBlockAndTintGetterExtension,LevelHeightAccessor,IBlockGetterExtension,LevelSimulatedReader

Members

addFreshEntity(entity as Entity) as bool
add an entity to the world, return if the entity is added successfully.
script.zs
// LevelAccessor.addFreshEntity(entity as Entity) as bool;
myLevelAccessor.addFreshEntity(myEntity);

Parameters:

entity Type: Entity

Return Type: bool

canSeeSkyFromBelowWater(pos as BlockPos) as bool
script.zs
// LevelAccessor.canSeeSkyFromBelowWater(pos as BlockPos) as bool;
myLevelAccessor.canSeeSkyFromBelowWater(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: bool

destroyBlock(pos as BlockPos, doDrops as bool) as bool
Destroys a block within the world.

Returns: Whether the block was changed.

script.zs
// LevelAccessor.destroyBlock(pos as BlockPos, doDrops as bool) as bool;
myLevelAccessor.destroyBlock(new BlockPos(0, 1, 2), true);

Parameters:

pos Type: BlockPos - The position of the block.
doDrops Type: bool - Whether the block drops itself and it's loot.

Return Type: bool

destroyBlock(pos as BlockPos, doDrops as bool, breaker as Entity) as bool
Destroys a block within the world.

Returns: Whether the block was changed.

script.zs
// LevelAccessor.destroyBlock(pos as BlockPos, doDrops as bool, breaker as Entity) as bool;
myLevelAccessor.destroyBlock(new BlockPos(0, 1, 2), true, player);

Parameters:

pos Type: BlockPos - The position of the block.
doDrops Type: bool - Whether the block drops itself and it's loot.
breaker Type: Entity - The entity to break the block.

Return Type: bool

Getter
Gets the difficulty setting for the world.
script.zs
// LevelAccessor.difficulty as Difficulty
myLevelAccessor.difficulty

Return Type: Difficulty

getBiome(pos as BlockPos) as Biome
Gets the biome at a given position.

Returns: The biome at the given position.

script.zs
// LevelAccessor.getBiome(pos as BlockPos) as Biome;
myLevelAccessor.getBiome(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: Biome

getBlockEntityData(pos as BlockPos) as IData
Gets the tile entity data for a tile entity at a given position.

Returns: The data of the tile entity.

script.zs
// LevelAccessor.getBlockEntityData(pos as BlockPos) as IData;
myLevelAccessor.getBlockEntityData(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position of the tile entity.

Return Type: IData

getBlockFloorHeight(pos as BlockPos) as double
script.zs
// LevelAccessor.getBlockFloorHeight(pos as BlockPos) as double;
myLevelAccessor.getBlockFloorHeight(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: double

getBlockState(pos as BlockPos) as BlockState
Gets the block state at a given position.

Returns: The block state at the position.

script.zs
// LevelAccessor.getBlockState(pos as BlockPos) as BlockState;
myLevelAccessor.getBlockState(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: BlockState

getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance
script.zs
// LevelAccessor.getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance;
myLevelAccessor.getCurrentDifficultyAt(myBlockPos);

Parameters:

position Type: BlockPos

Return Type: DifficultyInstance

getLightEmission(pos as BlockPos) as int
script.zs
// LevelAccessor.getLightEmission(pos as BlockPos) as int;
myLevelAccessor.getLightEmission(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: int

hasChunk(x as int, z as int) as bool
script.zs
// LevelAccessor.hasChunk(x as int, z as int) as bool;
myLevelAccessor.hasChunk(myInt, myInt);

Parameters:

x Type: int
z Type: int

Return Type: bool

Getter
script.zs
// LevelAccessor.isClientSide as bool
myLevelAccessor.isClientSide

Return Type: bool

isEmptyBlock(pos as BlockPos) as bool
Checks if the block at a given position is empty.

Returns: Whether the block is empty.

script.zs
// LevelAccessor.isEmptyBlock(pos as BlockPos) as bool;
myLevelAccessor.isEmptyBlock(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: bool

isWaterAt(pos as BlockPos) as bool
script.zs
// LevelAccessor.isWaterAt(pos as BlockPos) as bool;
myLevelAccessor.isWaterAt(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: bool

Getter
Gets the data for this level, holds information such as if it is raining, thundering, difficulty, etc
script.zs
// LevelAccessor.levelData as LevelData
myLevelAccessor.levelData

Return Type: LevelData

levelEvent(excluded as Player, event as int, position as BlockPos, extra as int)
Triggers a predetermined event on the client. Using this on a server or integrated server will send the event to all nearby players.
script.zs
// LevelAccessor.levelEvent(excluded as Player, event as int, position as BlockPos, extra as int);
myLevelAccessor.levelEvent(player, myInt, myBlockPos, myInt);

Parameters:

excluded Type: Player - An excluded player who will not receive the event.
event Type: int - The ID of the event to play.
position Type: BlockPos - The position of the event.
extra Type: int - Four bytes of additional data encoded as an integer. This
is generally unused.
levelEvent(event as int, position as BlockPos, extra as int)
Triggers a predetermined event on the client. Using this on a server or integrated server will send the event to all nearby players.
script.zs
// LevelAccessor.levelEvent(event as int, position as BlockPos, extra as int);
myLevelAccessor.levelEvent(myInt, myBlockPos, myInt);

Parameters:

event Type: int - The ID of the event to play.
position Type: BlockPos - The position of the event.
extra Type: int - Four bytes of additional data encoded as an integer. This
is generally unused.
Getter
script.zs
// LevelAccessor.maxLightLevel as int
myLevelAccessor.maxLightLevel

Return Type: int

playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource)
script.zs
// LevelAccessor.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource);
myLevelAccessor.playSound(myPlayer, myBlockPos, mySoundEvent, mySoundSource);

Parameters:

player Type: Player
position Type: BlockPos
event Type: SoundEvent
source Type: SoundSource
playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource, volume as float, pitch as float)
script.zs
// LevelAccessor.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource, volume as float, pitch as float);
myLevelAccessor.playSound(myPlayer, myBlockPos, mySoundEvent, mySoundSource, myFloat, myFloat);

Parameters:

player Type: Player
position Type: BlockPos
event Type: SoundEvent
source Type: SoundSource
volume Type: float
pitch Type: float
Getter
script.zs
// LevelAccessor.random as RandomSource
myLevelAccessor.random

Return Type: RandomSource

Getter
Gets the height of the sea level.
script.zs
// LevelAccessor.seaLevel as int
myLevelAccessor.seaLevel

Return Type: int

Getter
script.zs
// LevelAccessor.skyDarken as int
myLevelAccessor.skyDarken

Return Type: int