Level
Link to level
导入类
Link to 导入类
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 Copyimport crafttweaker.api.world.Level;
已实现的接口
Link to 已实现的接口
Level implements the following interfaces. That means all methods defined in these interfaces are also available in Level
- AutoCloseable
Casters
Link to casters
结果类型 | 是否隐藏 |
---|---|
结果类型 ServerLevel | 是否隐藏 false |
使用方式
Link to 使用方式
Name: addFreshEntity
add an entity to the world, return if the entity is added successfully.
Return Type: boolean
ZenScript CopyLevel.addFreshEntity(entity as Entity) as boolean
参数 | 类型 | 描述 |
---|---|---|
参数 entity | 类型 Entity | 描述 No Description Provided |
Name: asServerLevel
Return Type: ServerLevel
ZenScript Copy// Level.asServerLevel() as ServerLevel
myLevel.asServerLevel();
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);
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position of the block. |
参数 doDrops | 类型 布尔值 | 描述 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);
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position of the block. |
参数 doDrops | 类型 布尔值 | 描述 Whether the block drops itself and it's loot. |
参数 breaker | 类型 Entity | 描述 The entity to break the block. |
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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position to check. |
Name: getBlockEntity
Return Type: BlockEntity
ZenScript CopyLevel.getBlockEntity(pos as BlockPos) as BlockEntity
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 No Description Provided |
Name: getBlockEntityData
Gets the tile entity data for a tile entity at a given position.
Returns: The data of the tile entity.
Return Type: MapData
ZenScript Copy// Level.getBlockEntityData(pos as BlockPos) as MapData
myLevel.getBlockEntityData(new BlockPos(0, 1, 2));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position to look up. |
Name: getDayTime
Return Type: long
ZenScript Copy// Level.getDayTime() as long
myLevel.getDayTime();
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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 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());
参数 | 类型 | 描述 |
---|---|---|
参数 excludingEntity | 类型 Entity | 描述 No Description Provided |
参数 x1 | 类型 double | 描述 No Description Provided |
参数 y1 | 类型 double | 描述 No Description Provided |
参数 z1 | 类型 double | 描述 No Description Provided |
参数 x2 | 类型 double | 描述 No Description Provided |
参数 y2 | 类型 double | 描述 No Description Provided |
参数 z2 | 类型 double | 描述 No Description Provided |
参数 predicate | 类型 Predicate<Entity> | 描述 the entity filter |
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 CopyLevel.getEntitiesInArea<T : Entity>(pos1 as BlockPos, pos2 as BlockPos) as stdlib.List<T>
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|---|---|---|---|
参数 pos1 | 类型 BlockPos | 描述 No Description Provided | 可选 false | DefaultValue |
参数 pos2 | 类型 BlockPos | 描述 No Description Provided | 可选 true | DefaultValue |
参数 T | 类型 Entity | 描述 No Description Provided | 可选 N/A | DefaultValue N/A |
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));
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|---|---|---|---|
参数 excludingEntity | 类型 Entity | 描述 No Description Provided | 可选 false | DefaultValue |
参数 predicate | 类型 Predicate<Entity> | 描述 No Description Provided | 可选 false | DefaultValue |
参数 pos1 | 类型 BlockPos | 描述 No Description Provided | 可选 false | DefaultValue |
参数 pos2 | 类型 BlockPos | 描述 No Description Provided | 可选 true | DefaultValue |
Name: getEntitiesOfClass
Gets all entities in given area.
Returns: all entities in given area.
Return Type: stdlib.List<T>
ZenScript CopyLevel.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>
参数 | 类型 | 描述 |
---|---|---|
参数 x1 | 类型 double | 描述 No Description Provided |
参数 y1 | 类型 double | 描述 No Description Provided |
参数 z1 | 类型 double | 描述 No Description Provided |
参数 x2 | 类型 double | 描述 No Description Provided |
参数 y2 | 类型 double | 描述 No Description Provided |
参数 z2 | 类型 double | 描述 No Description Provided |
参数 T | 类型 Entity | 描述 No Description Provided |
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>);
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position to check. |
参数 direction | 类型 Direction | 描述 The direction to query. |
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.
Return Type: void
ZenScript Copy// Level.globalLevelEvent(eventId as int, pos as BlockPos, data as int) as void
myLevel.globalLevelEvent(2005, new BlockPos(0, 1, 2), 0);
参数 | 类型 | 描述 |
---|---|---|
参数 eventId | 类型 int | 描述 The ID of the event to play. |
参数 点 | 类型 BlockPos | 描述 The position of the event. |
参数 data | 类型 int | 描述 Four bytes of additional data encoded as an integer. This is generally unused. |
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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position to check. |
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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 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));
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position to check. |
Name: isRemote
Return Type: boolean
ZenScript Copy// Level.isRemote() as boolean
myLevel.isRemote();
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.
Return Type: void
ZenScript Copy// Level.levelEvent(excluded as Player, eventId as int, pos as BlockPos, data as int) as void
myLevel.levelEvent(player, 2005, new BlockPos(0, 1, 2), 0);
参数 | 类型 | 描述 |
---|---|---|
参数 excluded | 类型 Player | 描述 An excluded player who will not receive the event. |
参数 eventId | 类型 int | 描述 The ID of the event to play. |
参数 点 | 类型 BlockPos | 描述 The position of the event. |
参数 data | 类型 int | 描述 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);
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|---|---|---|---|
参数 startVec | 类型 Vec3 | 描述 a vector which describes the starting point | 可选 false | DefaultValue |
参数 endVec | 类型 Vec3 | 描述 a vector which describes the direction and length we are searching in | 可选 false | DefaultValue |
参数 blockMode | 类型 BlockClipContext | 描述 the type of block that the ray trace would stop at. | 可选 false | DefaultValue |
参数 fluidMode | 类型 FluidClipContext | 描述 the type of fluid that the ray trace would stop at. | 可选 false | DefaultValue |
参数 entity | 类型 Entity | 描述 the entity for selection context | 可选 true | DefaultValue |
Name: setBlockAndUpdate
Sets the block and it's 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>);
参数 | 类型 | 描述 |
---|---|---|
参数 点 | 类型 BlockPos | 描述 The position to set the block at. |
参数 state | 类型 BlockState | 描述 The new state of the block. |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 daytime | 类型 long | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 difficulty | 类型 string | 可获得 true | 可设置 false | 描述 Gets the difficulty setting for the world. |
名称 difficultyLocked | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if the difficulty of the world has been locked. |
名称 dimension | 类型 资源位置 | 可获得 true | 可设置 false | 描述 Gets the registry name of the dimension this world represents. |
名称 gameTime | 类型 long | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 hardcore | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if hardcore mode is enabled. |
名称 isClientSide | 类型 布尔值 | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 isDay | 类型 布尔值 | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 isNight | 类型 布尔值 | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 raining | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if it is raining. |
名称 random | 类型 Random | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 seaLevel | 类型 int | 可获得 true | 可设置 false | 描述 Gets the height of the sea level. |
名称 thundering | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if there is a thunder storm. |