Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
How do setMaxHealth to custom EntitySkeleton?

I want to create a custom Skeleton that has a name, more health and holds other custom items. I can add a name and setHealth(), but I can't setMaxHealth() and also setting items and armor just won't work.

Thanks for helping, here is my code:

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);


            }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

That can be obtained using the Attributable interface, as said in this thread from Spigot.


Example:

For 1.9 and over:

Entity boss;
Attributable bossAttributable = (Attributable) boss;
AttributeInstance ai = bossAttributable.getAttribute(Attribute.GENERIC_MAX_HEALTH);
ai.setValue(400.0);

For 1.8.8 and lower, this must be done another way:

Entity boss;
Damageable bossDamageable = (Damageable) boss;
bossDamageable.setMaxHealth(400.0);
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda