Level

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

Extends

Level extends CapabilityProvider<Level>.

Implements

Level implements the following interfaces:

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

Undocumented Interfaces

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
// Level.addFreshEntity(entity as Entity) as bool;
myLevel.addFreshEntity(myEntity);

Parameters:

entity Type: Entity

Return Type: bool

canSeeSkyFromBelowWater(pos as BlockPos) as bool
script.zs
// Level.canSeeSkyFromBelowWater(pos as BlockPos) as bool;
myLevel.canSeeSkyFromBelowWater(myBlockPos);

Parameters:

pos Type: BlockPos

Return Type: bool

Getter
script.zs
// Level.daytime as long
myLevel.daytime

Return Type: long

daytime() as long
script.zs
// Level.daytime() as long;
myLevel.daytime();

Return Type: long

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

Returns: Whether the block was changed.

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

Return Type: Difficulty

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

Return Type: ResourceLocation

Getter
script.zs
// Level.gameTime as long
myLevel.gameTime

Return Type: long

gameTime() as long
script.zs
// Level.gameTime() as long;
myLevel.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
// Level.getBestNeighborSignal(pos as BlockPos) as int;
myLevel.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
// Level.getBiome(pos as BlockPos) as Biome;
myLevel.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
// Level.getBlockEntity(pos as BlockPos) as BlockEntity;
myLevel.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
// Level.getBlockEntityData(pos as BlockPos) as IData;
myLevel.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
// Level.getBlockFloorHeight(pos as BlockPos) as double;
myLevel.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
// Level.getBlockState(pos as BlockPos) as BlockState;
myLevel.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
// Level.getCapability<T>(cap as Capability<T>, side as Direction) as T?;
myLevel.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
// Level.getCapability<T>(cap as Capability<T>) as T?;
myLevel.getCapability<T>(Capabilities.ENERGY);

Parameters:

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

Return Type: T?

getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance
script.zs
// Level.getCurrentDifficultyAt(position as BlockPos) as DifficultyInstance;
myLevel.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
// Level.getDirectSignalTo(pos as BlockPos) as int;
myLevel.getDirectSignalTo(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: int

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
// Level.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>;
myLevel.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
// Level.getEntitiesInArea<T : Entity>(pos1 as BlockPos, pos2 as BlockPos = null) as List<Entity>;
myLevel.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
// Level.getEntitiesInAreaExcluding(excludingEntity as Entity, predicate as function(t as Entity) as bool, pos1 as BlockPos, pos2 as BlockPos = null) as List<Entity>;
myLevel.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
// Level.getEntitiesOfClass<T : Entity>(x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double) as List<Entity>;
myLevel.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
// Level.getLightEmission(pos as BlockPos) as int;
myLevel.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
// Level.getSignal(pos as BlockPos, direction as Direction) as int;
myLevel.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
// Level.globalLevelEvent(eventId as int, pos as BlockPos, data as int);
myLevel.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
// Level.hasChunk(x as int, z as int) as bool;
myLevel.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
// Level.hasNeighborSignal(pos as BlockPos) as bool;
myLevel.hasNeighborSignal(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: bool

Getter
script.zs
// Level.isClientSide as bool
myLevel.isClientSide

Return Type: bool

Getter
script.zs
// Level.isDay as bool
myLevel.isDay

Return Type: bool

isDay() as bool
script.zs
// Level.isDay() as bool;
myLevel.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
// Level.isEmptyBlock(pos as BlockPos) as bool;
myLevel.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
// Level.isLoaded(pos as BlockPos) as bool;
myLevel.isLoaded(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to look up.

Return Type: bool

Getter
script.zs
// Level.isNight as bool
myLevel.isNight

Return Type: bool

isNight() as bool
script.zs
// Level.isNight() as bool;
myLevel.isNight();

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
// Level.isRainingAt(pos as BlockPos) as bool;
myLevel.isRainingAt(new BlockPos(0, 1, 2));

Parameters:

pos Type: BlockPos - The position to check.

Return Type: bool

isWaterAt(pos as BlockPos) as bool
script.zs
// Level.isWaterAt(pos as BlockPos) as bool;
myLevel.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
// Level.levelData as LevelData
myLevel.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
// Level.levelEvent(excluded as Player, event as int, position as BlockPos, extra as int);
myLevel.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
// Level.levelEvent(event as int, position as BlockPos, extra as int);
myLevel.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
// Level.maxLightLevel as int
myLevel.maxLightLevel

Return Type: int

playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource)
script.zs
// Level.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource);
myLevel.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
// Level.playSound(player as Player, position as BlockPos, event as SoundEvent, source as SoundSource, volume as float, pitch as float);
myLevel.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
// Level.raining as bool
myLevel.raining

Return Type: bool

Setter
Sets the current rain level.
script.zs
// Level.rainLevel = (level as float);
myLevel.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
// Level.rainLevel(level as float);
myLevel.rainLevel(0.5);

Parameters:

level Type: float - The new rain level between 0 and 1
Getter
script.zs
// Level.random as RandomSource
myLevel.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
// Level.rayTraceBlocks(startVec as Vec3, endVec as Vec3, blockMode as Block, fluidMode as Fluid, entity as Entity = null) as BlockHitResult;
myLevel.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
// Level.seaLevel as int
myLevel.seaLevel

Return Type: int

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
// Level.sequence(data as IData = new crafttweaker.api.data.MapData()) as SequenceBuilder<Level, IData>;
myLevel.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
// Level.sequence<T>(data as T) as SequenceBuilder<Level, T>;
myLevel.sequence<T>({version: "1.0.0"});

Parameters:

data Type: T

Return Type: SequenceBuilder<Level, T>

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
// Level.setBlockAndUpdate(pos as BlockPos, state as BlockState) as bool;
myLevel.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

Getter
script.zs
// Level.skyDarken as int
myLevel.skyDarken

Return Type: int

Getter
Checks if there is a thunder storm.
script.zs
// Level.thundering as bool
myLevel.thundering

Return Type: bool