ServerLevel

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

Extends

ServerLevel extends Level.

Implements

ServerLevel implements the following interfaces:

LevelAccessor,ICapabilityProviderImpl<ICapabilityProviderImpl>,ICapabilityProvider,CommonLevelAccessor,LevelReader,LevelSimulatedRW,BlockAndTintGetter,BlockGetter,LevelWriter,ServerLevelAccessor

Undocumented Interfaces

WorldGenLevel,ILevelExtension,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
// ServerLevel.addFreshEntity(entity as Entity) as bool;
myServerLevel.addFreshEntity(myEntity);

Parameters:

entity Type: Entity

Return Type: bool

addFreshEntityWithPassengers(entity as Entity)
script.zs
// ServerLevel.addFreshEntityWithPassengers(entity as Entity);
myServerLevel.addFreshEntityWithPassengers(myEntity);

Parameters:

entity Type: Entity
canSeeSkyFromBelowWater(pos as BlockPos) as bool
script.zs
// ServerLevel.canSeeSkyFromBelowWater(pos as BlockPos) as bool;
myServerLevel.canSeeSkyFromBelowWater(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: bool

Getter
Gets the custom data that is saved/loaded to/from disk when the level is saved/loaded to/from disk.

This lets you store data on this specific level, so data stored in the Overworld will not be accessible from the Nether.

script.zs
// ServerLevel.customData as CraftTweakerSavedData
myServerLevel.customData

Return Type: CraftTweakerSavedData

customData() as CraftTweakerSavedData
Gets the custom data that is saved/loaded to/from disk when the level is saved/loaded to/from disk.

This lets you store data on this specific level, so data stored in the Overworld will not be accessible from the Nether.

Returns: The custom data for this world.

script.zs
// ServerLevel.customData() as CraftTweakerSavedData;
myServerLevel.customData();

Return Type: CraftTweakerSavedData

Getter
script.zs
// ServerLevel.damageSources as DamageSources
myServerLevel.damageSources

Return Type: DamageSources

Getter
script.zs
// ServerLevel.daytime as long
myServerLevel.daytime

Return Type: long

daytime() as long
script.zs
// ServerLevel.daytime() as long;
myServerLevel.daytime();

Return Type: long

Setter
Sets the time of the Minecraft day.
script.zs
// ServerLevel.dayTime = (time as long);
myServerLevel.dayTime = myLong;

Parameters:

time Type: long - The new time of day. Should be between 0 and 24000.
destroyBlock(pos as BlockPos, doDrops as bool) as bool
Destroys a block within the world.

Returns: Whether the block was changed.

script.zs
// ServerLevel.destroyBlock(pos as BlockPos, doDrops as bool) as bool;
myServerLevel.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
// ServerLevel.destroyBlock(pos as BlockPos, doDrops as bool, breaker as Entity) as bool;
myServerLevel.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
// ServerLevel.difficulty as Difficulty
myServerLevel.difficulty

Return Type: Difficulty

Getter
Gets the registry name of the dimension this world represents.
script.zs
// ServerLevel.dimension as ResourceLocation
myServerLevel.dimension

Return Type: ResourceLocation

Getter
script.zs
// ServerLevel.gameTime as long
myServerLevel.gameTime

Return Type: long

gameTime() as long
script.zs
// ServerLevel.gameTime() as long;
myServerLevel.gameTime();

Return Type: long

getBestNeighborSignal(pos as BlockPos) as int
Gets the highest redstone signal available to a position from any of it's neighbors.

Returns: The highest redstone signal available to the position.

script.zs
// ServerLevel.getBestNeighborSignal(pos as BlockPos) as int;
myServerLevel.getBestNeighborSignal(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: int

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

Returns: The biome at the given position.

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

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: Biome

getBlockEntity(pos as BlockPos) as BlockEntity
script.zs
// ServerLevel.getBlockEntity(pos as BlockPos) as BlockEntity;
myServerLevel.getBlockEntity(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: BlockEntity

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
// ServerLevel.getBlockEntityData(pos as BlockPos) as IData;
myServerLevel.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
// ServerLevel.getBlockFloorHeight(pos as BlockPos) as double;
myServerLevel.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
// ServerLevel.getBlockState(pos as BlockPos) as BlockState;
myServerLevel.getBlockState(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: BlockState

getCapability(cap as Capability<T>, side as Direction) as T?
Gets the capability for the given side.

Returns: The found capability or null.

script.zs
// ServerLevel.getCapability<T>(cap as Capability<T>, side as Direction) as T?;
myServerLevel.getCapability<T>(Capabilities.ENERGY, <constant:minecraft:direction:north>);

Parameters:

cap Type: Capability<T> - The capability to get.
side Type: Direction - The side to get the capability from, can be null.

Return Type: T?

getCapability(cap as Capability<T>) as T?
Gets the capability.

Returns: The found capability or null.

script.zs
// ServerLevel.getCapability<T>(cap as Capability<T>) as T?;
myServerLevel.getCapability<T>(Capabilities.ENERGY);

Parameters:

cap Type: Capability<T> - The capability to get.

Return Type: T?

getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance
script.zs
// ServerLevel.getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance;
myServerLevel.getCurrentDifficultyAt(myBlockPos);

Parameters:

position Type: BlockPos

Return Type: DifficultyInstance

getDirectSignalTo(pos as BlockPos) as int
Gets the highest strong (direct) redstone signal of any neighboring block.

Returns: The highest strong (direct) redstone signal of all directly neighboring blocks.

script.zs
// ServerLevel.getDirectSignalTo(pos as BlockPos) as int;
myServerLevel.getDirectSignalTo(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: int

getEntities(predicate as function(t as Entity) as bool, type as EntityType<Entity> = null) as List<Entity>
Gets entities in the world that match the given Predicate and the given EntityType (if provided).

Returns: A List of Entities that match.

script.zs
// ServerLevel.getEntities(predicate as function(t as Entity) as bool, type as EntityType<Entity> = null) as List<Entity>;
myServerLevel.getEntities((entity as MCEntity) => entity.isImmuneToFire(), <entitytype:minecraft:sheep>);

Parameters:

predicate Type: function(t as Entity) as bool - The predicate to check against.
type (optional) Type: EntityType<Entity>

Default Value: null

Return Type: List<Entity>

getEntities(excludingEntity as Entity, x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double, predicate as function(t as Entity) as bool) as List<Entity>
Gets all entities in given area, excluding the one passed into it.
script.zs
// ServerLevel.getEntities(excludingEntity as Entity, x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double, predicate as function(t as Entity) as bool) as List<Entity>;
myServerLevel.getEntities(entity, 1.0, 1.0, 1.0, 11.4, 11.4, 11.4, (entityIn) => entityIn.isInWater());

Parameters:

excludingEntity Type: Entity
x1 Type: double
y1 Type: double
z1 Type: double
x2 Type: double
y2 Type: double
z2 Type: double
predicate Type: function(t as Entity) as bool - the entity filter

Return Type: List<Entity>

getEntitiesInArea(pos1 as BlockPos, pos2 as BlockPos = null) as List<Entity>
Gets all entities in given area, but the arguments are block poses. If pos2 is omitted, it will use pos1.add(1, 1, 1)

Returns: all entities in given area

script.zs
// ServerLevel.getEntitiesInArea<T : Entity>(pos1 as BlockPos, pos2 as BlockPos = null) as List<Entity>;
myServerLevel.getEntitiesInArea<T>(new BlockPos(0, 1, 2), new BlockPos(3, 4, 5));

Parameters:

pos1 Type: BlockPos
pos2 (optional) Type: BlockPos

Default Value: null

Return Type: List<Entity>

getEntitiesInAreaExcluding(excludingEntity as Entity, predicate as function(t as Entity) as bool, pos1 as BlockPos, pos2 as BlockPos = null) as List<Entity>
script.zs
// ServerLevel.getEntitiesInAreaExcluding(excludingEntity as Entity, predicate as function(t as Entity) as bool, pos1 as BlockPos, pos2 as BlockPos = null) as List<Entity>;
myServerLevel.getEntitiesInAreaExcluding(entity, (entityIn) => entityIn.isInWater(), new BlockPos(0, 1, 2), new BlockPos(3, 4, 5));

Parameters:

excludingEntity Type: Entity
predicate Type: function(t as Entity) as bool
pos1 Type: BlockPos
pos2 (optional) Type: BlockPos

Default Value: null

Return Type: List<Entity>

getEntitiesOfClass(x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double) as List<Entity>
Gets all entities in given area.

Returns: all entities in given area.

script.zs
// ServerLevel.getEntitiesOfClass<T : Entity>(x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double) as List<Entity>;
myServerLevel.getEntitiesOfClass<T>(1.0, 1.0, 1.0, 11.4, 11.4, 11.4);

Parameters:

x1 Type: double
y1 Type: double
z1 Type: double
x2 Type: double
y2 Type: double
z2 Type: double

Return Type: List<Entity>

getLightEmission(pos as BlockPos) as int
script.zs
// ServerLevel.getLightEmission(pos as BlockPos) as int;
myServerLevel.getLightEmission(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: int

getSignal(pos as BlockPos, direction as Direction) as int
Gets the redstone signal strength available to a position from a given direction.

Returns: The redstone signal strength available from that direction.

script.zs
// ServerLevel.getSignal(pos as BlockPos, direction as Direction) as int;
myServerLevel.getSignal(new BlockPos(0, 1, 2), <direction:north>);

Parameters:

pos Type: BlockPos - The position to check.
direction Type: Direction - The direction to query.

Return Type: int

globalLevelEvent(eventId as int, pos as BlockPos, data 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
// ServerLevel.globalLevelEvent(eventId as int, pos as BlockPos, data as int);
myServerLevel.globalLevelEvent(2005, new BlockPos(0, 1, 2), 0);

Parameters:

eventId Type: int - The ID of the event to play.
pos Type: BlockPos - The position of the event.
data Type: int - Four bytes of additional data encoded as an integer. This
is generally unused.
hasChunk(x as int, z as int) as bool
script.zs
// ServerLevel.hasChunk(x as int, z as int) as bool;
myServerLevel.hasChunk(myInt, myInt);

Parameters:

x Type: int
z Type: int

Return Type: bool

hasNeighborSignal(pos as BlockPos) as bool
Checks if a given position is receiving a redstone signal.

Returns: Whether the position is receiving a redstone signal.

script.zs
// ServerLevel.hasNeighborSignal(pos as BlockPos) as bool;
myServerLevel.hasNeighborSignal(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: bool

Getter
script.zs
// ServerLevel.isClientSide as bool
myServerLevel.isClientSide

Return Type: bool

Getter
script.zs
// ServerLevel.isDay as bool
myServerLevel.isDay

Return Type: bool

isDay() as bool
script.zs
// ServerLevel.isDay() as bool;
myServerLevel.isDay();

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
// ServerLevel.isEmptyBlock(pos as BlockPos) as bool;
myServerLevel.isEmptyBlock(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: bool

isLoaded(pos as BlockPos) as bool
Checks if the block at a given position is in a loaded chunk.

Returns: Whether the position is in a loaded chunk.

script.zs
// ServerLevel.isLoaded(pos as BlockPos) as bool;
myServerLevel.isLoaded(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: bool

Getter
script.zs
// ServerLevel.isNight as bool
myServerLevel.isNight

Return Type: bool

isNight() as bool
script.zs
// ServerLevel.isNight() as bool;
myServerLevel.isNight();

Return Type: bool

isRaided(pos as BlockPos) as bool
Checks if a position is within an active raid.

Returns: Whether the position was inside an active raid.

script.zs
// ServerLevel.isRaided(pos as BlockPos) as bool;
myServerLevel.isRaided(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: bool

isRainingAt(pos as BlockPos) as bool
Checks if it is raining at a specific position. This can never be true if the position does not have direct line of sight to the sky.

Returns: Whether it is raining at the current position.

script.zs
// ServerLevel.isRainingAt(pos as BlockPos) as bool;
myServerLevel.isRainingAt(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: bool

isSlimeChunk(pos as BlockPos) as bool
Checks if a position is within a chunk that is considered a slime chunk.

Returns: Whether the position was inside a slime chunk.

script.zs
// ServerLevel.isSlimeChunk(pos as BlockPos) as bool;
myServerLevel.isSlimeChunk(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: bool

isVillage(pos as BlockPos) as bool
Checks if a position is within a village.

Returns: Whether the position was inside a village.

script.zs
// ServerLevel.isVillage(pos as BlockPos) as bool;
myServerLevel.isVillage(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
// ServerLevel.isWaterAt(pos as BlockPos) as bool;
myServerLevel.isWaterAt(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: bool

Getter
script.zs
// ServerLevel.level as ServerLevel
myServerLevel.level

Return Type: ServerLevel

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

Return Type: int

playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource)
script.zs
// ServerLevel.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource);
myServerLevel.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
// ServerLevel.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource, volume as float, pitch as float);
myServerLevel.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
Checks if it is raining.
script.zs
// ServerLevel.raining as bool
myServerLevel.raining

Return Type: bool

Setter
Sets the current rain level.
script.zs
// ServerLevel.rainLevel = (level as float);
myServerLevel.rainLevel = myFloat;

Parameters:

level Type: float - The new rain level between 0 and 1
rainLevel(level as float)
Sets the current rain level.
script.zs
// ServerLevel.rainLevel(level as float);
myServerLevel.rainLevel(0.5);

Parameters:

level Type: float - The new rain level between 0 and 1
Getter
script.zs
// ServerLevel.random as RandomSource
myServerLevel.random

Return Type: RandomSource

rayTraceBlocks(startVec as Vec3, endVec as Vec3, blockMode as Block, fluidMode as Fluid, entity as Entity = null) as BlockHitResult
Creates a ray trace from one vector to the other vector, which will stop at a block or a fluid.

Returns: a BlockHitResult holding the result, the position and facing the ray stops.

script.zs
// ServerLevel.rayTraceBlocks(startVec as Vec3, endVec as Vec3, blockMode as Block, fluidMode as Fluid, entity as Entity = null) as BlockHitResult;
myServerLevel.rayTraceBlocks(new Vec3(0.0, 0.0, 0.0), new Vec3(1.1, 4.5, 1.4), RayTraceBlockMode.OUTLINE, RayTraceFluidMode.NONE, entity);

Parameters:

startVec Type: Vec3 - a vector which describes the starting point
endVec Type: Vec3 - a vector which describes the direction and length we are searching in
blockMode Type: BlockClipContext - the type of block that the ray trace would stop at.
fluidMode Type: FluidClipContext - the type of fluid that the ray trace would stop at.
entity (optional) Type: Entity - the entity for selection context

Default Value: null

Return Type: BlockHitResult

Getter
Gets the height of the sea level.
script.zs
// ServerLevel.seaLevel as int
myServerLevel.seaLevel

Return Type: int

Getter
Gets the random seed of the world.
script.zs
// ServerLevel.seed as long
myServerLevel.seed

Return Type: long

sequence(data as IData = new crafttweaker.api.data.MapData()) as SequenceBuilder<Level, IData>
Creates a new SequenceBuilder for this level.

SequenceBuilder's let you compose scripted events such as waiting 5 ticks, then setting the weather to rain.

Returns: A new SequenceBuilder for this level.

script.zs
// ServerLevel.sequence(data as IData = new crafttweaker.api.data.MapData()) as SequenceBuilder<Level, IData>;
myServerLevel.sequence({version: "1.0.0"});

Parameters:

data (optional) Type: IData

Default Value: new crafttweaker.api.data.MapData()

Return Type: SequenceBuilder<Level, IData>

sequence(data as T) as SequenceBuilder<Level, T>
Creates a new SequenceBuilder for this level.

SequenceBuilder's let you compose scripted events such as waiting 5 ticks, then setting the weather to rain.

Returns: A new SequenceBuilder for this level.

script.zs
// ServerLevel.sequence<T>(data as T) as SequenceBuilder<Level, T>;
myServerLevel.sequence<T>({version: "1.0.0"});

Parameters:

data Type: T

Return Type: SequenceBuilder<Level, T>

Getter
script.zs
// ServerLevel.server as MinecraftServer
myServerLevel.server

Return Type: Server

setBlockAndUpdate(pos as BlockPos, state as BlockState) as bool
Sets the block and its state at a given position.

Returns: Whether the block was changed.

script.zs
// ServerLevel.setBlockAndUpdate(pos as BlockPos, state as BlockState) as bool;
myServerLevel.setBlockAndUpdate(new BlockPos(0, 1, 2), <blockstate:minecraft:iron_block>);

Parameters:

pos Type: BlockPos - The position to set the block at.
state Type: BlockState - The new state of the block.

Return Type: bool

setTimeToDay()
Sets the time of the Minecraft day to day. This is like using the "time set day" command or setting the time to 1000.
script.zs
// ServerLevel.setTimeToDay();
myServerLevel.setTimeToDay();
setTimeToMidnight()
Sets the time of the Minecraft day to midnight. This is like using the "time set midnight" command or setting the time to 18000.
script.zs
// ServerLevel.setTimeToMidnight();
myServerLevel.setTimeToMidnight();
setTimeToNight()
Sets the time of the Minecraft day to night. This is like using the "time set night" command or setting the time to 13000.
script.zs
// ServerLevel.setTimeToNight();
myServerLevel.setTimeToNight();
setTimeToNoon()
Sets the time of the Minecraft day to noon. This is like using the "time set noon" command or setting the time to 6000.
script.zs
// ServerLevel.setTimeToNoon();
myServerLevel.setTimeToNoon();
Getter
script.zs
// ServerLevel.skyDarken as int
myServerLevel.skyDarken

Return Type: int

Getter
Checks if there is a thunder storm.
script.zs
// ServerLevel.thundering as bool
myServerLevel.thundering

Return Type: bool