Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!