IAura Chunk
Import
import mods.randomtweaker.naturesaura.IAuraChunk;Static ZenMethod
方法名
返回值类型
方法描述
Example
// 以下内容涉及事件, 不会事件请先学习事件
import crafttweaker.world.IWorld;
import crafttweaker.world.IBlockPos;
import crafttweaker.event.PlayerRightClickItemEvent; // 玩家右键物品事件
import mods.randomtweaker.naturesaura.IAuraChunk;
events.onPlayerRightClickItem(function(event as PlayerRightClickItemEvent) {
var world as IWorld = event.world; // 获取触发事件的玩家所在的世界
var pos as IBlockPos = event.position; // 获取玩家坐标
if(!world.remote && <minecraft:stick>.matches(event.item)) { // 先确保在服务端执行代码, 再判断手上物品是否为木棍
// event.position 返回触发事件的坐标, 在这里触发事件的是玩家, 所以坐标自然是玩家的坐标
// 获取玩家所在的灵气区块
var auraChunk as IAuraChunk = world.getAuraChunk(event.position);
// 消耗 1w 灵气量于玩家坐标上
auraChunk.drainAura(pos, 10000);
// 添加 1w 灵气量于玩家坐标上
auraChunk.storeAura(pos, 10000);
// 获取玩家坐标的灵气量
var amount as int = auraChunk.getDrainSpot(pos);
print(amount); // 打印 0, 打印结果会因为各种因素改变, Example 仅供参考
}
});Last updated