Quiero crear un esqueleto personalizado que tenga un nombre, más salud y contenga otros elementos personalizados. Puedo agregar un nombre y setHealth() , pero no puedo setMaxHealth() y también configurar elementos y armaduras simplemente no funcionará.
Gracias por ayudar, aquí está mi código:
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); }Eso se puede obtener usando la interfaz Atribuible, como se dice en este hilo de Spigot.
Ejemplo:
Para 1.9 y más:
Entity boss; Attributable bossAttributable = (Attributable) boss; AttributeInstance ai = bossAttributable.getAttribute(Attribute.GENERIC_MAX_HEALTH); ai.setValue(400.0);Para 1.8.8 y versiones anteriores, esto debe hacerse de otra manera:
Entity boss; Damageable bossDamageable = (Damageable) boss; bossDamageable.setMaxHealth(400.0);