Importare la Classe

Link to importare-la-classe

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.world.Level;

Extending CapabilityProvider<Level>

Link to extending-capabilityproviderlevel

Level extends CapabilityProvider<Level>. That means all methods available in CapabilityProvider<Level> are also available in Level

Interfacce Implementate

Link to interfacce-implementate

Level implements the following interfaces. That means all methods defined in these interfaces are also available in Level

  • AutoCloseable

Name: addFreshEntity

add an entity to the world, return if the entity is added successfully.

Return Type: boolean

ZenScript
Copy
Level.addFreshEntity(entity as Entity) as boolean
ParametroTipo
Parametro
entity
Tipo
Entity

Name: destroyBlock

Destroys a block within the world.

Returns: Whether the block was changed.
Return Type: boolean

ZenScript
Copy
// Level.destroyBlock(pos as BlockPos, doDrops as boolean) as boolean

myLevel.destroyBlock(new BlockPos(0, 1, 2), true);
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position of the block.
Parametro
doDrops
Tipo
boolean
Descrizione
Whether the block drops itself and it's loot.

Name: destroyBlock

Destroys a block within the world.

Returns: Whether the block was changed.
Return Type: boolean

ZenScript
Copy
// Level.destroyBlock(pos as BlockPos, doDrops as boolean, breaker as Entity?) as boolean

myLevel.destroyBlock(new BlockPos(0, 1, 2), true, player);
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position of the block.
Parametro
doDrops
Tipo
boolean
Descrizione
Whether the block drops itself and it's loot.
Parametro
breaker
Tipo
Entity?
Descrizione
The entity to break the block.

Link to getBestNeighborSignal

Name: getBestNeighborSignal

Gets the highest redstone signal available to a position from any of it's neighbors.

Returns: The highest redstone signal available to the position.
Return Type: int

ZenScript
Copy
// Level.getBestNeighborSignal(pos as BlockPos) as int

myLevel.getBestNeighborSignal(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to check.

Name: getBiome

Gets the biome at a given position.

Returns: The biome at the given position.
Return Type: Biome

ZenScript
Copy
// Level.getBiome(pos as BlockPos) as Biome

myLevel.getBiome(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to look up.

Name: getBlockEntity

Return Type: BlockEntity?

ZenScript
Copy
Level.getBlockEntity(pos as BlockPos) as BlockEntity?
ParametroTipo
Parametro
pos
Tipo
BlockPos

Link to getBlockEntityData

Name: getBlockEntityData

Gets the tile entity data for a tile entity at a given position.

Returns: The data of the tile entity.
Return Type: IData

ZenScript
Copy
// Level.getBlockEntityData(pos as BlockPos) as IData

myLevel.getBlockEntityData(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position of the tile entity.

Name: getBlockState

Gets the block state at a given position.

Returns: The block state at the position.
Return Type: BlockState

ZenScript
Copy
// Level.getBlockState(pos as BlockPos) as BlockState

myLevel.getBlockState(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to look up.

Name: getDayTime

Return Type: long

ZenScript
Copy
// Level.getDayTime() as long

myLevel.getDayTime();

Link to getDirectSignalTo

Name: getDirectSignalTo

Gets the highest strong (direct) redstone signal of any neighboring block.

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

ZenScript
Copy
// Level.getDirectSignalTo(pos as BlockPos) as int

myLevel.getDirectSignalTo(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to check.

Name: getEntities

Gets all entities in given area, excluding the one passed into it.

Return Type: stdlib.List<Entity>

ZenScript
Copy
// 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 Predicate<Entity>) as stdlib.List<Entity>

myLevel.getEntities(entity, 1.0, 1.0, 1.0, 11.4, 11.4, 11.4, (entityIn) => entityIn.isInWater());
ParametroTipoDescrizione
Parametro
excludingEntity
Tipo
Entity?
Descrizione
Parametro
x1
Tipo
double
Descrizione
Parametro
y1
Tipo
double
Descrizione
Parametro
z1
Tipo
double
Descrizione
Parametro
x2
Tipo
double
Descrizione
Parametro
y2
Tipo
double
Descrizione
Parametro
z2
Tipo
double
Descrizione
Parametro
predicate
Tipo
Predicate<Entity>
Descrizione
the entity filter

Link to getEntitiesInArea

Name: getEntitiesInArea

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
Return Type: stdlib.List<T>

ZenScript
Copy
Level.getEntitiesInArea<T : Entity>(pos1 as BlockPos, pos2 as BlockPos) as stdlib.List<T>
ParametroTipoOptional
Parametro
pos1
Tipo
BlockPos
Optional
no
Parametro
pos2
Tipo
BlockPos
Optional
Parametro
T
Tipo
Entity
Optional

Link to getEntitiesInAreaExcluding

Name: getEntitiesInAreaExcluding

Return Type: stdlib.List<Entity>

ZenScript
Copy
// Level.getEntitiesInAreaExcluding(excludingEntity as Entity?, predicate as Predicate<Entity>, pos1 as BlockPos, pos2 as BlockPos) as stdlib.List<Entity>

myLevel.getEntitiesInAreaExcluding(entity, (entityIn) => entityIn.isInWater(), new BlockPos(0, 1, 2), new BlockPos(3, 4, 5));
ParametroTipoOptional
Parametro
excludingEntity
Tipo
Entity?
Optional
no
Parametro
predicate
Tipo
Predicate<Entity>
Optional
no
Parametro
pos1
Tipo
BlockPos
Optional
no
Parametro
pos2
Tipo
BlockPos
Optional

Link to getEntitiesOfClass

Name: getEntitiesOfClass

Gets all entities in given area.

Returns: all entities in given area.
Return Type: stdlib.List<T>

ZenScript
Copy
Level.getEntitiesOfClass<T : Entity>(x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double) as stdlib.List<T>
ParametroTipo
Parametro
x1
Tipo
double
Parametro
y1
Tipo
double
Parametro
z1
Tipo
double
Parametro
x2
Tipo
double
Parametro
y2
Tipo
double
Parametro
z2
Tipo
double
Parametro
T
Tipo
Entity

Name: getGametime

Return Type: long

ZenScript
Copy
// Level.getGametime() as long

myLevel.getGametime();

Name: getSignal

Gets the redstone signal strength available to a position from a given direction.

Returns: The redstone signal strength available from that direction.
Return Type: int

ZenScript
Copy
// Level.getSignal(pos as BlockPos, direction as Direction) as int

myLevel.getSignal(new BlockPos(0, 1, 2), <direction:north>);
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to check.
Parametro
direction
Tipo
Direction
Descrizione
The direction to query.

Link to globalLevelEvent

Name: globalLevelEvent

Triggers a predetermined event on the client. Using this on a server or integrated server will send the event to all nearby players.

ZenScript
Copy
// Level.globalLevelEvent(eventId as int, pos as BlockPos, data as int)

myLevel.globalLevelEvent(2005, new BlockPos(0, 1, 2), 0);
ParametroTipoDescrizione
Parametro
eventId
Tipo
int
Descrizione
The ID of the event to play.
Parametro
pos
Tipo
BlockPos
Descrizione
The position of the event.
Parametro
data
Tipo
int
Descrizione
Four bytes of additional data encoded as an integer. This
is generally unused.

Link to hasNeighborSignal

Name: hasNeighborSignal

Checks if a given position is receiving a redstone signal.

Returns: Whether the position is receiving a redstone signal.
Return Type: boolean

ZenScript
Copy
// Level.hasNeighborSignal(pos as BlockPos) as boolean

myLevel.hasNeighborSignal(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to check.

Name: isClientSide

Return Type: boolean

ZenScript
Copy
// Level.isClientSide() as boolean

myLevel.isClientSide();

Name: isDay

Return Type: boolean

ZenScript
Copy
// Level.isDay() as boolean

myLevel.isDay();

Name: isEmptyBlock

Checks if the block at a given position is empty.

Returns: Whether the block is empty.
Return Type: boolean

ZenScript
Copy
// Level.isEmptyBlock(pos as BlockPos) as boolean

myLevel.isEmptyBlock(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to look up.

Name: isLoaded

Checks if the block at a given position is in a loaded chunk.

Returns: Whether the position is in a loaded chunk.
Return Type: boolean

ZenScript
Copy
// Level.isLoaded(pos as BlockPos) as boolean

myLevel.isLoaded(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to look up.

Name: isNight

Return Type: boolean

ZenScript
Copy
// Level.isNight() as boolean

myLevel.isNight();

Name: isRainingAt

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.
Return Type: boolean

ZenScript
Copy
// Level.isRainingAt(pos as BlockPos) as boolean

myLevel.isRainingAt(new BlockPos(0, 1, 2));
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to check.

Name: levelEvent

Triggers a predetermined event on the client. Using this on a server or integrated server will send the event to all nearby players.

ZenScript
Copy
// Level.levelEvent(excluded as Player?, eventId as int, pos as BlockPos, data as int)

myLevel.levelEvent(player, 2005, new BlockPos(0, 1, 2), 0);
ParametroTipoDescrizione
Parametro
excluded
Tipo
Player?
Descrizione
An excluded player who will not receive the event.
Parametro
eventId
Tipo
int
Descrizione
The ID of the event to play.
Parametro
pos
Tipo
BlockPos
Descrizione
The position of the event.
Parametro
data
Tipo
int
Descrizione
Four bytes of additional data encoded as an integer. This
is generally unused.

Name: rayTraceBlocks

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.
Return Type: BlockHitResult

ZenScript
Copy
// Level.rayTraceBlocks(startVec as Vec3, endVec as Vec3, blockMode as BlockClipContext, fluidMode as FluidClipContext, entity as Entity) 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);
ParametroTipoDescrizioneOptional
Parametro
startVec
Tipo
Vec3
Descrizione
a vector which describes the starting point
Optional
no
Parametro
endVec
Tipo
Vec3
Descrizione
a vector which describes the direction and length we are searching in
Optional
no
Parametro
blockMode
Tipo
BlockClipContext
Descrizione
the type of block that the ray trace would stop at.
Optional
no
Parametro
fluidMode
Tipo
FluidClipContext
Descrizione
the type of fluid that the ray trace would stop at.
Optional
no
Parametro
entity
Tipo
Entity
Descrizione
the entity for selection context
Optional

Name: sequence

Creates a new SequenceBuilder<T,U> for this level.

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

Returns: A new SequenceBuilder<T,U> for this level.
Return Type: SequenceBuilder<Level,MapData>

ZenScript
Copy
// Level.sequence(data as MapData) as SequenceBuilder<Level,MapData>

myLevel.sequence({version: "1.0.0"});
ParametroTipoOptionalDefault Value
Parametro
data
Tipo
MapData
Optional
Default Value
new crafttweaker.api.data.MapData()

Name: sequence

Creates a new SequenceBuilder<T,U> for this level.

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

Returns: A new SequenceBuilder<T,U> for this level.
Return Type: SequenceBuilder<Level,T>

ZenScript
Copy
// Level.sequence<T : Object>(data as T) as SequenceBuilder<Level,T>

myLevel.sequence<crafttweaker.api.data.MapData>({version: "1.0.0"});
ParametroTipo
Parametro
data
Tipo
T
Parametro
T
Tipo
Object

Link to setBlockAndUpdate

Name: setBlockAndUpdate

Sets the block and its state at a given position.

Returns: Whether the block was changed.
Return Type: boolean

ZenScript
Copy
// Level.setBlockAndUpdate(pos as BlockPos, state as BlockState) as boolean

myLevel.setBlockAndUpdate(new BlockPos(0, 1, 2), <blockstate:minecraft:iron_block>);
ParametroTipoDescrizione
Parametro
pos
Tipo
BlockPos
Descrizione
The position to set the block at.
Parametro
state
Tipo
BlockState
Descrizione
The new state of the block.

Name: setRainingLevel

Sets the current rain level.

ZenScript
Copy
// Level.setRainingLevel(level as float)

myLevel.setRainingLevel(0.5);
ParametroTipoDescrizione
Parametro
level
Tipo
float
Descrizione
The new rain level between 0 and 1
NomeTipoHa GetterHa SetterDescrizione
Nome
daytime
Tipo
long
Ha Getter
Ha Setter
no
Descrizione
Nome
difficulty
Tipo
string
Ha Getter
Ha Setter
no
Descrizione
Gets the difficulty setting for the world.
Nome
difficultyLocked
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Checks if the difficulty of the world has been locked.
Nome
dimension
Tipo
ResourceLocation
Ha Getter
Ha Setter
no
Descrizione
Gets the registry name of the dimension this world represents.
Nome
gameTime
Tipo
long
Ha Getter
Ha Setter
no
Descrizione
Nome
hardcore
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Checks if hardcore mode is enabled.
Nome
isClientSide
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Nome
isDay
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Nome
isNight
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Nome
rainLevel
Tipo
Level
Ha Getter
no
Ha Setter
Descrizione
Sets the current rain level.
Nome
raining
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Checks if it is raining.
Nome
random
Tipo
RandomSource
Ha Getter
Ha Setter
no
Descrizione
Nome
seaLevel
Tipo
int
Ha Getter
Ha Setter
no
Descrizione
Gets the height of the sea level.
Nome
thundering
Tipo
boolean
Ha Getter
Ha Setter
no
Descrizione
Checks if there is a thunder storm.