GameType
Link to gametype
导入类
Link to 导入类
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 Copyimport crafttweaker.api.world.GameType;
Enum Constants
Link to enum-constants
GameType is an enum. It has 4 enum constants. They are accessible using the code below.
ZenScript Copy<constant:minecraft:world/gametype:survival>
<constant:minecraft:world/gametype:creative>
<constant:minecraft:world/gametype:adventure>
<constant:minecraft:world/gametype:spectator>
使用方式
Link to 使用方式
Name: getId
Return Type: int
ZenScript Copy// GameType.getId() as int
myGameType.getId();
Name: getLongDisplayName
Return Type: Component
ZenScript Copy// GameType.getLongDisplayName() as Component
myGameType.getLongDisplayName();
Name: getName
Return Type: string
ZenScript Copy// GameType.getName() as string
myGameType.getName();
Name: getShortDisplayName
Return Type: Component
ZenScript Copy// GameType.getShortDisplayName() as Component
myGameType.getShortDisplayName();
Name: isBlockPlacingRestricted
Return Type: boolean
ZenScript Copy// GameType.isBlockPlacingRestricted() as boolean
myGameType.isBlockPlacingRestricted();
Name: isCreative
Return Type: boolean
ZenScript Copy// GameType.isCreative() as boolean
myGameType.isCreative();
Name: isSurvival
Return Type: boolean
ZenScript Copy// GameType.isSurvival() as boolean
myGameType.isSurvival();
Name: updatePlayerAbilities
ZenScript CopyGameType.updatePlayerAbilities(abilities as Abilities)
参数 | 类型 |
---|---|
参数 abilities | 类型 Abilities |
名称 | 类型 | 可获得 | 可设置 |
---|---|---|---|
名称 id | 类型 int | 可获得 true | 可设置 false |
名称 isBlockPlacingRestricted | 类型 布尔值 | 可获得 true | 可设置 false |
名称 isCreative | 类型 布尔值 | 可获得 true | 可设置 false |
名称 isSurvival | 类型 布尔值 | 可获得 true | 可设置 false |
名称 longDisplayName | 类型 Component | 可获得 true | 可设置 false |
名称 name(名称) | 类型 string | 可获得 true | 可设置 false |
名称 shortDisplayName | 类型 Component | 可获得 true | 可设置 false |