Bug Closed · Resolved

1.16.2 Entity has vanilla attributes when spawned via API

#969 opened by Unknown 5 years ago

Unknownreported this bug

Here I debug with a small code that displays attributes of LivingEntity on PlayerInteractEntityEvent: [Legacy attachment omitted]

It still does not have exactly 200 hp and 8 damage when spawned via command but very close.

Config:

CatAllBlack:
  Type: WOLF
  Tameable: false
  Display: '&8Vantablack'
  Health: 200
  Damage: 8
  LevelModifiers:
  - health 5
  - damage 1

My code:

MobManager mobManager = MythicMobs.inst().getMobManager();
ActiveMob activeMob = mobManager.spawnMob(petCode, spawnLoc, petLevel);
AbstractEntity entity = activeMob.getEntity();
Tameable pet = (Tameable) entity.getBukkitEntity();
pet.setSilent(true);
pet.setTamed(true);
pet.setOwner(owner);
pet.setCustomNameVisible(true);

// health
int maxHP = (int) (pet.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() + 0.5);
GuardiansOfAdelia.getInstance().getLogger().info("Pet maxHP: " + maxHP);

The last line in my code says 20 health too.

Unknowncommented

Can we get a startup log if this hasn't been fixed yet? @Lix3nn53

Unknowncommented

Hey sorry for not replying, I found the reason for this bug and it does not seem related to MythicMobs. But there is a problem with MythicMobs mobs level modifiers? First I will explain the bug about vanilla attributes, then I will explain the problem about level modifiers.

Cause of the reseting to vanilla attr: As you can see I am using Tameable#setOwner spigot method. I dont know why but this method resets the Attirbute's of wolf. Sets max health to 20 and attack to 4.

Alternative fix I am using: https://pastebin.pl/view/36e603cf

This code works perfectly and calculates health and damage values according to pet level. But when I spawn the same mob with /mm mobs spawn PetWolf command it has wrong max health which is 476. Should not it have 500 max hp at level 1 and 505 at level 2?(Tested with almost no other plugins)(Also tested with Zombie entity instead of Wolf, also 476 health) Here is my mob configuration: https://pastebin.pl/view/dc04c7a4

Server: Paper 1.16.4

MythicMobs version: 4.10.0-SNAPSHOT

If you want logs tell me what conditions you want and I can send.

Sign in to join the discussion.