Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

IWorld

The IWorld object contains information on a Dimension within the game.

Importing the class

It might be required to import the class to avoid errors.
import crafttweaker.world.IWorld

Extending IBlockProperties

IWorld extends IBlockAccess. That means that all methods that are available to IBlockAccess objects are also available to IWorld.

Creating an IWorld object

Normally, you can derive this object from entities or other functions. If you need to create it yourself though, this is the way to go:
Note that this method should only be called inside functions that are meant to be run inside minecraft, not during the loading circle.

script.zs
crafttweaker.world.IWorld.getFromID(int id);

ZenMethods without parameters and ZenGetters

ZenMethodZenGetterReturn typeDescription
ZenMethod
isRemote()
ZenGetter
remote
Return type
boolean
Description
True if the world is a “slave” client; changes will not be saved or propagated from this world. For example, server worlds have this set to false, client worlds have this set to true.
ZenMethod
isRaining()
ZenGetter
raining
Return type
boolean
Description
Returns true if it is currently raining.
ZenMethod
getMoonPhase()
ZenGetter
moonPhase
Return type
int
Description
Returns the current moon phase.
ZenMethod
isDayTime()
ZenGetter
dayTime
Return type
boolean
Description
Checks if it is daytime.
ZenMethod
getWorldTime()
ZenGetter
time
Return type
long
Description
Returns the world’s time.
ZenMethod
getDimension()
ZenGetter
dimension
Return type
int
Description
Returns the world’s dimension.
ZenMethod
isSurfaceWorld()
ZenGetter
surfaceWorld
Return type
boolean
Description
Returns whether you are in a surface world or not.
ZenMethod
getDimensionType()
ZenGetter
dimensionType
Return type
String
Description
Returns the dimension’s type name.
ZenMethod
getWorldType()
ZenGetter
worldType
Return type
String
Description
Returns the world’s type name.
ZenMethod
getWorldInfo()
ZenGetter
worldInfo
Return type
IWorldInfo
Description
Returns the world’s information. Can be used to retrieve even more info on the world.
ZenMethod
getProvider()
ZenGetter
provider
Return type
IWorldProvider
Description
Returns the world’s provider. Can be used to retrieve even more info on the world.
ZenMethod
getSeaLevel()
ZenGetter
seaLevel
Return type
int
Description
Returns the world’s sea level.
ZenMethod
getRandom()
ZenGetter
random
Return type
IRandom
Description
Returns the world’s random generator

ZenMethods with parameters

Get Biome at specific Position

Use either an IPosition3f or an IBlockPos object.
Returns an IBiome Object.

script.zs
worldObj.getBiome(IPosition3f position);
worldObj.getBiome(IBlockPos position);

Get Brightness at specific Position

Use either three ints or an IBlockPos object. Returns an int.

script.zs
worldObj.getBrightness(int x, int y, int z);
worldObj.getBrightness(IBlockPos position);

Get Block at specific Position

Use either three ints or an IBlockPos object. Returns an IBlock Object.

script.zs
worldObj.getBlock(int x, int y, int z);
worldObj.getBlock(IBlockPos position);

Get or Set a blockState at a specific Position

Use an IBlockPos Object and for the setter also an IBlockState Object. Optionally an IData object can be specified to define NBT data for the blockstate’s TileEntity when it is set. Getter Returns an IBlockState, setter a bool.

script.zs
worldObj.getBlockState(IBlockPos pos);
worldObj.setBlockState(IBlockState state, IBlockPos pos);
worldObj.setBlockState(IBlockState state, IData tileEntityData, IBlockPos pos);

Spawn Entity

Use an IEntity object.
Returns a bool that states if the spawn was successful.

script.zs
worldObj.spawnEntity(IEntity entity);

Create Lightningbolt

Returns the Lightningbolt as an IEntity object.

script.zs
worldObj.createLightningBolt(double x, double y, double z, @Optional boolean effectOnly);

Add a Weather Effect

Use an IEntity object.
Returns a bool that states if the spawn was successful.

script.zs
worldObj.addWeatherEffect(IEntity entity);

Remove Entity

Use an IEntity object.
Returns a bool that states if the remove was successful.

script.zs
worldObj.removeEntity(IEntity entity);

Get a raytrace result

Use two IVector3d objects, and three booleans to get an IRayTraceResult.
Can be null

The first vector describes the starting point, the 2nd vector the direction and length we are searching in.
Only the last parameter is true by default.

script.zs
worldObj.rayTraceBlocks(IVector3d begin, IVector3d ray, @Optional boolean stopOnLiquid, @Optional boolean ignoreBlockWithoutBoundingBox, @Optional(true) boolean returnLastUncollidableBlock)

Get the picked block

Use an IBlockPos, an IRayTraceResult and an IPlayer.
Returns an IItemStack.
Can be null

Gets the IItemStack that would be obtained by picking the block at the position.

script.zs
worldObj.getPickedBlock(IBlockPos pos, IRayTraceResult rayTraceResult, IPlayer player);

Check if a position is a spawn chunk

Returns a bool that states if the position is a spawn chunk.

script.zs
worldObj.isSpawnChunk(int x, int z);

Extinguish Fire

Returns a bool.

script.zs
worldObj.extinguishFire(IPlayer player, IBlockPos pos, IFacing side);

Create an explosion object

Use an IEntity, three doubles, a float, and two booleans. Returns an IExplosion.

Creates an IExplosion in the world at the given coordinates. The explosion will have the specified placer (can be null), as well as the size of the explosion and whether it should cause fire and/or cause terrain damage, respectively.

script.zs
worldObj.createExplosion(IEntity exploder, double x, double y, double z, float size, bool causesFire, bool damagesTerrain);

Perform an explosion in the world

Create & perform in the same method

Use an IEntity, three doubles, a float, and two booleans. Returns the created and performed IExplosion.

Creates and performs an IExplosion in the world at the given coordinates. The explosion will have the specified placer (can be null), as well as the size of the explosion and whether it should cause fire and/or cause terrain damage, respectively.

script.zs
worldObj.performExplosion(IEntity exploder, double x, double y, double z, float size, bool causesFire, bool damagesTerrain);

Only perform an existing explosion

Use an IExplosion. Returns the performed IExplosion.

Performs the IExplosion in the world.

script.zs
worldObj.performExplosion(IExplosion explosion);