GameType

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.

script.zs
import crafttweaker.api.world.GameType;

Implemented Interfaces

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

Enum Constants

GameType is an enum. It has 4 enum constants. They are accessible using the code below.

script.zs
<constant:minecraft:world/gametype:survival>
<constant:minecraft:world/gametype:creative>
<constant:minecraft:world/gametype:adventure>
<constant:minecraft:world/gametype:spectator>

Methods

Return Type: int

script.zs
// GameType.getId() as int
myGameType.getId();

Return Type: Component

script.zs
// GameType.getLongDisplayName() as Component
myGameType.getLongDisplayName();

Return Type: string

script.zs
// GameType.getName() as string
myGameType.getName();

Return Type: Component

script.zs
// GameType.getShortDisplayName() as Component
myGameType.getShortDisplayName();

Return Type: boolean

script.zs
// GameType.isBlockPlacingRestricted() as boolean
myGameType.isBlockPlacingRestricted();

Return Type: boolean

script.zs
// GameType.isCreative() as boolean
myGameType.isCreative();

Return Type: boolean

script.zs
// GameType.isSurvival() as boolean
myGameType.isSurvival();
script.zs
GameType.updatePlayerAbilities(abilities as Abilities)
ParameterType
Parameter
abilities
Type
Abilities

Properties

NameTypeHas GetterHas Setter
Name
id
Type
int
Has Getter
true
Has Setter
false
Name
isBlockPlacingRestricted
Type
boolean
Has Getter
true
Has Setter
false
Name
isCreative
Type
boolean
Has Getter
true
Has Setter
false
Name
isSurvival
Type
boolean
Has Getter
true
Has Setter
false
Name
longDisplayName
Type
Component
Has Getter
true
Has Setter
false
Name
name
Type
string
Has Getter
true
Has Setter
false
Name
shortDisplayName
Type
Component
Has Getter
true
Has Setter
false