Max health is now correctly set on entity spawn
This commit is contained in:
		| @@ -28,6 +28,7 @@ import org.bukkit.Location; | ||||
| import org.bukkit.Material; | ||||
| import org.bukkit.entity.Ageable; | ||||
| import org.bukkit.entity.Arrow; | ||||
| import org.bukkit.entity.Damageable; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.entity.EntityType; | ||||
| import org.bukkit.entity.ExperienceOrb; | ||||
| @@ -145,6 +146,25 @@ public class PacketsManager { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { | ||||
|             if (disguise.getWatcher() instanceof LivingWatcher) { | ||||
|                 PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); | ||||
|                 List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>(); | ||||
|                 Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth"); | ||||
|                 if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { | ||||
|                     builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth()); | ||||
|                 } else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity() && disguisedEntity instanceof Damageable) { | ||||
|                     builder.baseValue(((Damageable) disguisedEntity).getMaxHealth()); | ||||
|                 } else { | ||||
|                     builder.baseValue(DisguiseValues.getDisguiseValues(disguise.getType()).getMaxHealth()); | ||||
|                 } | ||||
|                 builder.packet(packet); | ||||
|                 attributes.add(builder.build()); | ||||
|                 packet.getIntegers().write(0, disguisedEntity.getEntityId()); | ||||
|                 packet.getAttributeCollectionModifier().write(0, attributes); | ||||
|                 packets.add(packet); | ||||
|             } | ||||
|         } | ||||
|         PacketContainer[] spawnPackets = new PacketContainer[2 + packets.size()]; | ||||
|         for (int i = 0; i < packets.size(); i++) { | ||||
|             spawnPackets[i + 2] = packets.get(i); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user