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

Diese Klasse importieren

Link to diese-klasse-importieren

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

Extending IBlockProperties

Link to 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

Link to 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.

ZenScript
Copy
crafttweaker.world.IWorld.getFromID(int id);

ZenMethods without parameters and ZenGetters

Link to zenmethods-without-parameters-and-zengetters

ZenMethodZenGetterRückgabetypBeschreibung
ZenMethod
isRemote()
ZenGetter
remote
Rückgabetyp
boolean
Beschreibung
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
Rückgabetyp
boolean
Beschreibung
Returns true if it is currently raining.
ZenMethod
getMoonPhase()
ZenGetter
moonPhase
Rückgabetyp
int
Beschreibung
Returns the current moon phase.
ZenMethod
isDayTime()
ZenGetter
dayTime
Rückgabetyp
boolean
Beschreibung
Checks if it is daytime.
ZenMethod
getWorldTime()
ZenGetter
time
Rückgabetyp
long
Beschreibung
Returns the world's time.
ZenMethod
getDimension()
ZenGetter
dimension
Rückgabetyp
int
Beschreibung
Returns the world's dimension.
ZenMethod
isSurfaceWorld()
ZenGetter
surfaceWorld
Rückgabetyp
boolean
Beschreibung
Returns whether you are in a surface world or not.
ZenMethod
getDimensionType()
ZenGetter
dimensionType
Rückgabetyp
String
Beschreibung
Returns the dimension's type name.
ZenMethod
getWorldType()
ZenGetter
worldType
Rückgabetyp
String
Beschreibung
Returns the world's type name.
ZenMethod
getWorldInfo()
ZenGetter
worldInfo
Rückgabetyp
IWorldInfo
Beschreibung
Returns the world's information. Can be used to retrieve even more info on the world.
ZenMethod
getProvider()
ZenGetter
provider
Rückgabetyp
IWorldProvider
Beschreibung
Returns the world's provider. Can be used to retrieve even more info on the world.
ZenMethod
getSeaLevel()
ZenGetter
seaLevel
Rückgabetyp
int
Beschreibung
Returns the world's sea level.
ZenMethod
getRandom()
ZenGetter
random
Rückgabetyp
IRandom
Beschreibung
Returns the world's random generator

ZenMethods with parameters

Link to zenmethods-with-parameters

Get Biome at specific Position

Link to get-biome-at-specific-position

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

ZenScript
Copy
worldObj.getBiome(IPosition3f position);
worldObj.getBiome(IBlockPos position);

Get Brightness at specific Position

Link to get-brightness-at-specific-position

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

ZenScript
Copy
worldObj.getBrightness(int x, int y, int z);
worldObj.getBrightness(IBlockPos position);

Get Block at specific Position

Link to get-block-at-specific-position

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

ZenScript
Copy
worldObj.getBlock(int x, int y, int z);
worldObj.getBlock(IBlockPos position);

Get or Set a blockState at a specific Position

Link to 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.

ZenScript
Copy
worldObj.getBlockState(IBlockPos pos);
worldObj.setBlockState(IBlockState state, IBlockPos pos);
worldObj.setBlockState(IBlockState state, IData tileEntityData, IBlockPos pos);

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

ZenScript
Copy
worldObj.spawnEntity(IEntity entity);

Create Lightningbolt

Link to create-lightningbolt

Returns the Lightningbolt as an IEntity object.

ZenScript
Copy
worldObj.createLightningBolt(double x, double y, double z, @Optional boolean effectOnly);

Add a Weather Effect

Link to add-a-weather-effect

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

ZenScript
Copy
worldObj.addWeatherEffect(IEntity entity);

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

ZenScript
Copy
worldObj.removeEntity(IEntity entity);

Get a raytrace result

Link to 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.

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

Get the picked block

Link to 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.

ZenScript
Copy
worldObj.getPickedBlock(IBlockPos pos, IRayTraceResult rayTraceResult, IPlayer player);

Check if a position is a spawn chunk

Link to check-if-a-position-is-a-spawn-chunk

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

ZenScript
Copy
worldObj.isSpawnChunk(int x, int z);

Returns a bool.

ZenScript
Copy
worldObj.extinguishFire(IPlayer player, IBlockPos pos, IFacing side);

Create an explosion object

Link to 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.

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

Perform an explosion in the world

Link to perform-an-explosion-in-the-world

Create & perform in the same method

Link to 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.

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

Only perform an existing explosion

Link to only-perform-an-existing-explosion

Use an IExplosion. Returns the performed IExplosion.

Performs the IExplosion in the world.

ZenScript
Copy
worldObj.performExplosion(IExplosion explosion);