EntityAttributeAPI

EntityAttributeAPI.class

类型

方法

描述

static void

addEntityAttribute(Entity entity, String source, List attributeList, boolean release)

给实体添加一个来自某个 源 的属性,相同的源会被覆盖

static boolean

deleteEntityAttribute(Entity entity, String source)

清除实体身上由某个源所增加的属性

static boolean

getSourceAttribute(Entity entity, String source)

获取实体身上某个源的属性列表

static boolean

isSource(Entity entity, String source)

判断实体身上是否存在某个源

"addAttribute(Entity entity, String source, List attributeList, boolean release)" 内的 release 为 true 时则属性更新时就自动释放,如果为false则持久生效,需要 "deleteAttribute(Entity entity, String source)" 方法来删除

我想给怪物增加一些属性该怎么做?

通过addEntityAttribute(Player player, String source, List attributeList) 方法,需要注意的是相同的 source 将会覆盖掉原来 source 上的属性,与AttributeAPI内的方法相同

Entity entity;
List<String> attributeList = Arrays.asList("物理伤害: 10-20","生命力: 100");
EntityAttributeAPI.addEntityAttribute(entity, "测试源", attributeList);

最后更新于

这有帮助吗?