我想要创建一个自定义骨架,其中有一个名称,更多的健康,并持有其他自定义项目。我可以添加一个名称和setHealth()
,但我不能setMaxHealth()
和设置项目和盔甲只是不能工作。
谢谢你的帮助,这是我的代码:
Player p = (Player) sender;
WorldServer world = ((CraftWorld)p.getWorld()).getHandle();
Location loc = p.getLocation();
if (args.length > 0) {
if (args[0].equalsIgnoreCase("define")) {
//get worldedit selection
if (getWorldEdit().getSelection(p) == null) {
p.sendMessage(title + "Please select a region with WorldEdit");
return false;
}
s = getWorldEdit().getSelection(p);
Location min = s.getMinimumPoint();
Location max = s.getMaximumPoint();
//boss mob creation
EntitySkeleton boss = new EntitySkeleton(world);
boss.setHealth(400);
boss.setCustomName("§4§lDAFT BOSS");
boss.setCustomNameVisible(true);
ItemStack weapon = new ItemStack(Material.DIAMOND_SWORD);
weapon.setDurability((short) 0);
weapon.addEnchantment(Enchantment.DAMAGE_ALL, 5);
weapon.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
boss.setLocation(max);
world.addEntity(boss);
}
发布于 2017-04-29 23:19:33
这可以使用属性接口获得,就像在这线程中所说的那样。
示例:
1.9及以上:
Entity boss;
Attributable bossAttributable = (Attributable) boss;
AttributeInstance ai = bossAttributable.getAttribute(Attribute.GENERIC_MAX_HEALTH);
ai.setValue(400.0);
对于1.8.8和更低的人,必须采取另一种方式:
Entity boss;
Damageable bossDamageable = (Damageable) boss;
bossDamageable.setMaxHealth(400.0);
https://stackoverflow.com/questions/43701216
复制相似问题