ServerLevelAccessor

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.ServerLevelAccessor;

Implements

ServerLevelAccessor implements the following interfaces:

LevelAccessor,CommonLevelAccessor,LevelReader,LevelSimulatedRW,BlockAndTintGetter,BlockGetter,LevelWriter

Undocumented Interfaces

LevelTimeAccess,EntityGetter,CollisionGetter,SignalGetter,NoiseBiomeSource,ILevelReaderExtension,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
// ServerLevelAccessor.addFreshEntity(entity as Entity) as bool;
myServerLevelAccessor.addFreshEntity(myEntity);

Parameters:

entity Type: Entity

Return Type: bool

addFreshEntityWithPassengers(entity as Entity)
script.zs
// ServerLevelAccessor.addFreshEntityWithPassengers(entity as Entity);
myServerLevelAccessor.addFreshEntityWithPassengers(myEntity);

Parameters:

entity Type: Entity
canSeeSkyFromBelowWater(pos as BlockPos) as bool
script.zs
// ServerLevelAccessor.canSeeSkyFromBelowWater(pos as BlockPos) as bool;
myServerLevelAccessor.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
// ServerLevelAccessor.destroyBlock(pos as BlockPos, doDrops as bool) as bool;
myServerLevelAccessor.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
// ServerLevelAccessor.destroyBlock(pos as BlockPos, doDrops as bool, breaker as Entity) as bool;
myServerLevelAccessor.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
// ServerLevelAccessor.difficulty as Difficulty
myServerLevelAccessor.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
// ServerLevelAccessor.getBiome(pos as BlockPos) as Biome;
myServerLevelAccessor.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
// ServerLevelAccessor.getBlockEntityData(pos as BlockPos) as IData;
myServerLevelAccessor.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
// ServerLevelAccessor.getBlockFloorHeight(pos as BlockPos) as double;
myServerLevelAccessor.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
// ServerLevelAccessor.getBlockState(pos as BlockPos) as BlockState;
myServerLevelAccessor.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
// ServerLevelAccessor.getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance;
myServerLevelAccessor.getCurrentDifficultyAt(myBlockPos);

Parameters:

position Type: BlockPos

Return Type: DifficultyInstance

getLightEmission(pos as BlockPos) as int
script.zs
// ServerLevelAccessor.getLightEmission(pos as BlockPos) as int;
myServerLevelAccessor.getLightEmission(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: int

hasChunk(x as int, z as int) as bool
script.zs
// ServerLevelAccessor.hasChunk(x as int, z as int) as bool;
myServerLevelAccessor.hasChunk(myInt, myInt);

Parameters:

x Type: int
z Type: int

Return Type: bool

Getter
script.zs
// ServerLevelAccessor.isClientSide as bool
myServerLevelAccessor.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
// ServerLevelAccessor.isEmptyBlock(pos as BlockPos) as bool;
myServerLevelAccessor.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
// ServerLevelAccessor.isWaterAt(pos as BlockPos) as bool;
myServerLevelAccessor.isWaterAt(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: bool

Getter
script.zs
// ServerLevelAccessor.level as ServerLevel
myServerLevelAccessor.level

Return Type: ServerLevel

Getter
Gets the data for this level, holds information such as if it is raining, thundering, difficulty, etc
script.zs
// ServerLevelAccessor.levelData as LevelData
myServerLevelAccessor.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
// ServerLevelAccessor.levelEvent(excluded as Player, event as int, position as BlockPos, extra as int);
myServerLevelAccessor.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
// ServerLevelAccessor.levelEvent(event as int, position as BlockPos, extra as int);
myServerLevelAccessor.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
// ServerLevelAccessor.maxLightLevel as int
myServerLevelAccessor.maxLightLevel

Return Type: int

playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource)
script.zs
// ServerLevelAccessor.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource);
myServerLevelAccessor.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
// ServerLevelAccessor.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource, volume as float, pitch as float);
myServerLevelAccessor.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
// ServerLevelAccessor.random as RandomSource
myServerLevelAccessor.random

Return Type: RandomSource

Getter
Gets the height of the sea level.
script.zs
// ServerLevelAccessor.seaLevel as int
myServerLevelAccessor.seaLevel

Return Type: int

Getter
script.zs
// ServerLevelAccessor.skyDarken as int
myServerLevelAccessor.skyDarken

Return Type: int