XpChangeEvent
Link to xpchangeevent
This event is fired when the player's xp count is changed. If the amount is positive the xp is being added. If the xp is negative, the xp is being removed. This event takes place before the xp has changed, allowing you to change the amount, or negate the change entirely.
The event is cancelable.
If the event is canceled, the xp 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.XpChangeEvent;
Extending PlayerXpEvent
Link to extending-playerxpevent
XpChangeEvent extends PlayerXpEvent. That means all methods available in PlayerXpEvent are also available in XpChangeEvent
使用方式
Link to 使用方式
Name: getXp
Gets the amount of xp that the player's xp counter is being changed by.
Returns: The amount of xp that the player's xp counter is being changed by.
Return Type: int
ZenScript Copy// XpChangeEvent.getXp() as int
event.getXp();
Name: setXp
Sets the amount of xp to change the player's xp counter by.
ZenScript Copy// XpChangeEvent.setXp(amount as int)
event.setXp(15);
参数 | 类型 | 描述 |
---|---|---|
参数 amount | 类型 int | 描述 The amount of xp that the player's xp counter should be changed by. |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 xp (经验值) | 类型 int | 可获得 true | 可设置 true | 描述 Gets the amount of xp that the player's xp counter is being changed by. |