LevelChangeEvent
Link to levelchangeevent
This event is fired when the player's level count is changed. If the amount is positive the levels are being added. If they are negative, levels are being removed. This event takes place before the levels are changed. This allows you to change the amount of levels, or cancel the change entirely.
The event is cancelable.
If the event is canceled, the xp level will not change
The event does not have a result.
导入类
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.event.entity.player.xp.LevelChangeEvent;
Extending PlayerXpEvent
Link to extending-playerxpevent
LevelChangeEvent extends PlayerXpEvent. That means all methods available in PlayerXpEvent are also available in LevelChangeEvent
使用方式
Link to 使用方式
Name: getLevels
Gets the amount of levels that the player's level is being changed by.
Returns: The amount of levels that the player's level is being changed by.
Return Type: int
ZenScript Copy// LevelChangeEvent.getLevels() as int
event.getLevels();
Name: setLevels
Sets the amount of levels to change the player's level by.
ZenScript Copy// LevelChangeEvent.setLevels(levels as int)
event.setLevels(5);
参数 | 类型 | 描述 |
---|---|---|
参数 levels | 类型 int | 描述 The amount of levels that should be added to the player's level counter. |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 levels | 类型 int | 可获得 true | 可设置 true | 描述 Gets the amount of levels that the player's level is being changed by. |