Worlds represent a dimension within the game. They are used to interact with the blocks, mobs, and other variables within that dimension.

Импорт класса

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
Copy
import crafttweaker.api.world.MCWorld;

Implemented Interfaces

Link to implemented-interfaces

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

  • AutoCloseable
Тип результатаЯвляется неявным
Тип результата
MCBlockDisplayReader
Является неявным
true
Тип результата
MCServerWorld
Является неявным
false

Name: addEntity

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

Return Type: boolean

ZenScript
Copy
MCWorld.addEntity(entity as MCEntity) as boolean
ПараметрТипОписание
Параметр
entity
Тип
MCEntity
Описание
No Description Provided

Link to asBlockDisplayReader

Name: asBlockDisplayReader

Return Type: MCBlockDisplayReader

ZenScript
Copy
// MCWorld.asBlockDisplayReader() as MCBlockDisplayReader

world.asBlockDisplayReader();

Name: asServerWorld

Return Type: MCServerWorld

ZenScript
Copy
// MCWorld.asServerWorld() as MCServerWorld

world.asServerWorld();

Name: destroyBlock

Destroys a block within the world.

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

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

world.destroyBlock(new BlockPos(0, 1, 2), true);
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position of the block.
Параметр
doDrops
Тип
boolean
Описание
Whether or not the block drops itself and it's loot.

Name: destroyBlock

Destroys a block within the world.

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

ZenScript
Copy
// MCWorld.destroyBlock(pos as BlockPos, doDrops as boolean, breaker as MCEntity) as boolean

world.destroyBlock(new BlockPos(0, 1, 2), true, player);
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position of the block.
Параметр
doDrops
Тип
boolean
Описание
Whether or not the block drops itself and it's loot.
Параметр
breaker
Тип
MCEntity
Описание
The entity to break the block.

Name: getBiome

Gets the biome at a given position.

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

ZenScript
Copy
// MCWorld.getBiome(pos as BlockPos) as MCBiome

world.getBiome(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to look up.

Name: getBlockState

Gets the block state at a given position.

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

ZenScript
Copy
// MCWorld.getBlockState(pos as BlockPos) as MCBlockState

world.getBlockState(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to look up.

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<MCEntity>

ZenScript
Copy
// MCWorld.getEntitiesInArea(pos1 as BlockPos, pos2 as BlockPos) as stdlib.List<MCEntity>

world.getEntitiesInArea(new BlockPos(0, 1, 2), new BlockPos(3, 4, 5));
ПараметрТипОписаниеOptionalDefaultValue
Параметр
pos1
Тип
BlockPos
Описание
No Description Provided
Optional
false
DefaultValue
Параметр
pos2
Тип
BlockPos
Описание
No Description Provided
Optional
true
DefaultValue

Link to getEntitiesInArea

Name: getEntitiesInArea

Gets all entities in given area.

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

ZenScript
Copy
// MCWorld.getEntitiesInArea(x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double) as stdlib.List<MCEntity>

world.getEntitiesInArea(1.0, 1.0, 1.0, 11.4, 11.4, 11.4);
ПараметрТипОписание
Параметр
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

Link to getEntitiesInAreaExcluding

Name: getEntitiesInAreaExcluding

Return Type: stdlib.List<MCEntity>

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

world.getEntitiesInAreaExcluding(entity, (entityIn) => entityIn.isInWater(), new BlockPos(0, 1, 2), new BlockPos(3, 4, 5));
ПараметрТипОписаниеOptionalDefaultValue
Параметр
excludingEntity
Тип
MCEntity?
Описание
No Description Provided
Optional
false
DefaultValue
Параметр
predicate
Тип
Predicate<MCEntity>
Описание
No Description Provided
Optional
false
DefaultValue
Параметр
pos1
Тип
BlockPos
Описание
No Description Provided
Optional
false
DefaultValue
Параметр
pos2
Тип
BlockPos
Описание
No Description Provided
Optional
true
DefaultValue

Link to getEntitiesInAreaExcluding

Name: getEntitiesInAreaExcluding

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

Return Type: stdlib.List<MCEntity>

ZenScript
Copy
// MCWorld.getEntitiesInAreaExcluding(excludingEntity as MCEntity?, x1 as double, y1 as double, z1 as double, x2 as double, y2 as double, z2 as double, predicate as Predicate<MCEntity>) as stdlib.List<MCEntity>

world.getEntitiesInAreaExcluding(entity, 1.0, 1.0, 1.0, 11.4, 11.4, 11.4, (entityIn) => entityIn.isInWater());
ПараметрТипОписание
Параметр
excludingEntity
Тип
MCEntity?
Описание
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<MCEntity>
Описание
the entity filter

Link to getRedstonePower

Name: getRedstonePower

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
// MCWorld.getRedstonePower(pos as BlockPos, direction as Direction) as int

world.getRedstonePower(new BlockPos(0, 1, 2), <direction:north>);
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to check.
Параметр
direction
Тип
Direction
Описание
The direction to query.

Link to getRedstonePowerFromNeighbors

Name: getRedstonePowerFromNeighbors

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
// MCWorld.getRedstonePowerFromNeighbors(pos as BlockPos) as int

world.getRedstonePowerFromNeighbors(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to check.

Name: getStrongPower

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
// MCWorld.getStrongPower(pos as BlockPos) as int

world.getStrongPower(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to check.

Name: getTileData

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
// MCWorld.getTileData(pos as BlockPos) as IData

world.getTileData(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position of the tile entity.

Name: getTileEntity

Return Type: MCTileEntity?

ZenScript
Copy
MCWorld.getTileEntity(pos as BlockPos) as MCTileEntity?
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
No Description Provided

Name: isAir

Checks if the block at a given position is air.

Returns: Whether or not the block is air.
Return Type: boolean

ZenScript
Copy
// MCWorld.isAir(pos as BlockPos) as boolean

world.isAir(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to look up.

Name: isBlockPowered

Checks if a given position is receiving a redstone signal.

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

ZenScript
Copy
// MCWorld.isBlockPowered(pos as BlockPos) as boolean

world.isBlockPowered(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to check.

Name: isLoaded

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

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

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

world.isLoaded(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to look up.

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 or not it is raining at the current position.
Return Type: boolean

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

world.isRainingAt(new BlockPos(0, 1, 2));
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to check.

Name: isRemote

Checks if the world is remote. This is always true on the rendering thread.

Returns: Whether or not the world is remote.
Return Type: boolean

ZenScript
Copy
// MCWorld.isRemote() as boolean

world.isRemote();

Name: playEvent

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
// MCWorld.playEvent(eventId as int, pos as BlockPos, data as int) as void

world.playEvent(2005, new BlockPos(0, 1, 2), 0);
ПараметрТипОписание
Параметр
eventId
Тип
int
Описание
The ID of the event to play.
Параметр
pos
Тип
BlockPos
Описание
The position of the event.
Параметр
data
Тип
int
Описание
Four bytes of additional data encoded as an integer. This
is generally unused.

Name: playEvent

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
// MCWorld.playEvent(excluded as MCPlayerEntity, eventId as int, pos as BlockPos, data as int) as void

world.playEvent(player, 2005, new BlockPos(0, 1, 2), 0);
ПараметрТипОписание
Параметр
excluded
Тип
MCPlayerEntity
Описание
An excluded player who will not receive the event.
Параметр
eventId
Тип
int
Описание
The ID of the event to play.
Параметр
pos
Тип
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 BlockRayTraceResult holding the result, the position and facing the ray stops.
Return Type: BlockRayTraceResult

ZenScript
Copy
// MCWorld.rayTraceBlocks(startVec as MCVector3d, endVec as MCVector3d, blockMode as RayTraceBlockMode, fluidMode as RayTraceFluidMode, entity as MCEntity) as BlockRayTraceResult

world.rayTraceBlocks(new MCVector3d(0.0, 0.0, 0.0), new MCVector3d(1.1, 4.5, 1.4), RayTraceBlockMode.OUTLINE, RayTraceFluidMode.NONE, entity);
ПараметрТипОписаниеOptionalDefaultValue
Параметр
startVec
Тип
MCVector3d
Описание
a vector which describes the starting point
Optional
false
DefaultValue
Параметр
endVec
Тип
MCVector3d
Описание
a vector which describes the direction and length we are searching in
Optional
false
DefaultValue
Параметр
blockMode
Тип
RayTraceBlockMode
Описание
the type of block that the ray trace would stop at.
Optional
false
DefaultValue
Параметр
fluidMode
Тип
RayTraceFluidMode
Описание
the type of fluid that the ray trace would stop at.
Optional
false
DefaultValue
Параметр
entity
Тип
MCEntity
Описание
the entity for selection context
Optional
true
DefaultValue

Name: setBlockState

Sets the block and it's state at a given position.

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

ZenScript
Copy
// MCWorld.setBlockState(pos as BlockPos, state as MCBlockState) as boolean

world.setBlockState(new BlockPos(0, 1, 2), <blockstate:minecraft:iron_block>);
ПараметрТипОписание
Параметр
pos
Тип
BlockPos
Описание
The position to set the block at.
Параметр
state
Тип
MCBlockState
Описание
The new state of the block.

Свойства

Link to свойства

НазваниеТипИмеет GetterИмеет SetterОписание
Название
dayTime
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if it is day time in the world. Different dimensions will have
different logic for how this is determined.
Название
difficulty
Тип
string
Имеет Getter
true
Имеет Setter
false
Описание
Gets the difficulty setting for the world.
Название
difficultyLocked
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if the difficulty of the world has been locked.
Название
dimension
Тип
string
Имеет Getter
true
Имеет Setter
false
Описание
Gets the registry name of the dimension this world represents.
Название
gameTime
Тип
long
Имеет Getter
true
Имеет Setter
false
Описание
Gets the current game time in ticks.
Название
hardcore
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if hardcore mode is enabled.
Название
nightTime
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if it is night time in the world. Different dimensions will have
different logic for how this is determined.
Название
raining
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if it is raining.
Название
random
Тип
Random
Имеет Getter
true
Имеет Setter
false
Описание
No Description Provided
Название
remote
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if the world is remote. This is always true on the rendering
thread.
Название
seaLevel
Тип
int
Имеет Getter
true
Имеет Setter
false
Описание
Gets the height of the sea level.
Название
thundering
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Описание
Checks if there is a thunder storm.
Название
timeOfDay
Тип
long
Имеет Getter
true
Имеет Setter
false
Описание
Gets the current time of the day in ticks.