MCWorld

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

Importing the class

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

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

  • AutoCloseable

Casters

Result typeIs Implicit
MCServerWorldfalse

Methods

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
ParameterTypeDescription
entityMCEntityNo Description Provided
asServerWorld

Return Type: MCServerWorld

ZenScript
Copy
MCWorld.asServerWorld() as MCServerWorld
world.asServerWorld();
destroyBlock

Destroys a block within the world.

Return Type: boolean

ZenScript
Copy
MCWorld.destroyBlock(pos as BlockPos, doDrops as boolean) as boolean
world.destroyBlock(new BlockPos(0, 1, 2), true);
ParameterTypeDescription
posBlockPosThe position of the block.
doDropsbooleanWhether or not the block drops itself and it's loot.
destroyBlock

Destroys a block within the world.

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);
ParameterTypeDescription
posBlockPosThe position of the block.
doDropsbooleanWhether or not the block drops itself and it's loot.
breakerMCEntityThe entity to break the block.
getBiome

Gets the biome at a given position.

Return Type: MCBiome

ZenScript
Copy
MCWorld.getBiome(pos as BlockPos) as MCBiome
world.getBiome(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position to look up.
getBlockState

Gets the block state at a given position.

Return Type: MCBlockState

ZenScript
Copy
MCWorld.getBlockState(pos as BlockPos) as MCBlockState
world.getBlockState(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position to look up.
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)

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));
ParameterTypeDescriptionOptionalDefaultValue
pos1BlockPosNo Description Providedfalse
pos2BlockPosNo Description Providedtrue
getEntitiesInArea

Gets 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);
ParameterTypeDescription
x1doubleNo Description Provided
y1doubleNo Description Provided
z1doubleNo Description Provided
x2doubleNo Description Provided
y2doubleNo Description Provided
z2doubleNo Description Provided
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));
ParameterTypeDescriptionOptionalDefaultValue
excludingEntityMCEntity?No Description Providedfalse
predicatePredicate<MCEntity>No Description Providedfalse
pos1BlockPosNo Description Providedfalse
pos2BlockPosNo Description Providedtrue
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());
ParameterTypeDescription
excludingEntityMCEntity?No Description Provided
x1doubleNo Description Provided
y1doubleNo Description Provided
z1doubleNo Description Provided
x2doubleNo Description Provided
y2doubleNo Description Provided
z2doubleNo Description Provided
predicatePredicate<MCEntity>the entity filter
getRedstonePower

Gets the redstone signal strength available to a position from a given 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>);
ParameterTypeDescription
posBlockPosThe position to check.
directionDirectionThe direction to query.
getRedstonePowerFromNeighbors

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

Return Type: int

ZenScript
Copy
MCWorld.getRedstonePowerFromNeighbors(pos as BlockPos) as int
world.getRedstonePowerFromNeighbors(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position to check.
getStrongPower

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

Return Type: int

ZenScript
Copy
MCWorld.getStrongPower(pos as BlockPos) as int
world.getStrongPower(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position to check.
getTileData

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

Return Type: IData

ZenScript
Copy
MCWorld.getTileData(pos as BlockPos) as IData
world.getTileData(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position of the tile entity.
isAir

Checks if the block at a given position is air.

Return Type: boolean

ZenScript
Copy
MCWorld.isAir(pos as BlockPos) as boolean
world.isAir(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position to look up.
isBlockPowered

Checks if a given 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));
ParameterTypeDescription
posBlockPosThe position to check.
isLoaded

Checks if the block at a given 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));
ParameterTypeDescription
posBlockPosThe position to look up.
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.

Return Type: boolean

ZenScript
Copy
MCWorld.isRainingAt(pos as BlockPos) as boolean
world.isRainingAt(new BlockPos(0, 1, 2));
ParameterTypeDescription
posBlockPosThe position to check.
isRemote

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

Return Type: boolean

ZenScript
Copy
MCWorld.isRemote() as boolean
world.isRemote();
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);
ParameterTypeDescription
eventIdintThe ID of the event to play.
posBlockPosThe position of the event.
dataintFour bytes of additional data encoded as an integer. This
is generally unused.
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);
ParameterTypeDescription
excludedMCPlayerEntityAn excluded player who will not receive the event.
eventIdintThe ID of the event to play.
posBlockPosThe position of the event.
dataintFour bytes of additional data encoded as an integer. This
is generally unused.
setBlockState

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

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>);
ParameterTypeDescription
posBlockPosThe position to set the block at.
stateMCBlockStateThe new state of the block.

Properties

NameTypeHas GetterHas Setter
dayTimebooleantruefalse
difficultystringtruefalse
difficultyLockedbooleantruefalse
dimensionstringtruefalse
gameTimelongtruefalse
hardcorebooleantruefalse
nightTimebooleantruefalse
rainingbooleantruefalse
randomRandomtruefalse
remotebooleantruefalse
seaLevelinttruefalse
thunderingbooleantruefalse
timeOfDaylongtruefalse