Объект IWorld содержит информацию об измерении в игре.

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

Link to импорт-класса

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

Наследование от IBlockProperties

Link to наследование-от-iblockproperties

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

Создание объекта IWorld

Link to создание-объекта-iworld

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

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