mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-14 11:21:23 +01:00
Fix LivingEntity Damage Event Packet (#2209)
This commit is contained in:
parent
e513efb393
commit
d5c6126a6b
@ -21,10 +21,7 @@ import net.minestom.server.inventory.EquipmentHandler;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.ConnectionState;
|
||||
import net.minestom.server.network.packet.server.LazyPacket;
|
||||
import net.minestom.server.network.packet.server.play.CollectItemPacket;
|
||||
import net.minestom.server.network.packet.server.play.EntityAnimationPacket;
|
||||
import net.minestom.server.network.packet.server.play.EntityAttributesPacket;
|
||||
import net.minestom.server.network.packet.server.play.SoundEffectPacket;
|
||||
import net.minestom.server.network.packet.server.play.*;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.scoreboard.Team;
|
||||
@ -333,8 +330,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
sendPacketToViewersAndSelf(new EntityAnimationPacket(getEntityId(), EntityAnimationPacket.Animation.TAKE_DAMAGE));
|
||||
}
|
||||
|
||||
//todo
|
||||
// sendPacketToViewersAndSelf(new DamageEventPacket(getEntityId(), damage.getType().id(), 0, 0, null));
|
||||
sendPacketToViewersAndSelf(new DamageEventPacket(getEntityId(), damage.getTypeId(), damage.getAttacker() == null ? 0 : damage.getAttacker().getEntityId() + 1, damage.getSource() == null ? 0 : damage.getSource().getEntityId() + 1, damage.getSourcePosition()));
|
||||
|
||||
// Additional hearts support
|
||||
if (this instanceof Player player) {
|
||||
|
@ -35,8 +35,11 @@ public class Damage implements Taggable {
|
||||
/**
|
||||
* Creates a new damage type.
|
||||
*
|
||||
* @param attacker The attacker that initiated this damage
|
||||
* @param source The source of the damage. For direct hits (melee), this will be the same as the attacker. For indirect hits (projectiles), this will be the projectile
|
||||
* @param type the type of this damage
|
||||
* @param amount amount of damage
|
||||
* @param sourcePosition The position of the source of damage
|
||||
*/
|
||||
public Damage(@NotNull DynamicRegistry.Key<DamageType> type, @Nullable Entity source, @Nullable Entity attacker, @Nullable Point sourcePosition, float amount) {
|
||||
this.typeKey = type;
|
||||
@ -51,7 +54,7 @@ public class Damage implements Taggable {
|
||||
/**
|
||||
* Gets the type of this damage.
|
||||
* <p>
|
||||
* It does not have to be unique to this object.o
|
||||
* It does not have to be unique to this object.
|
||||
*
|
||||
* @return the damage type
|
||||
*/
|
||||
@ -59,6 +62,12 @@ public class Damage implements Taggable {
|
||||
return typeKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the integer id of the damage type that has been set
|
||||
* @return The integer id of the damage type
|
||||
*/
|
||||
public int getTypeId() { return DAMAGE_TYPE_REGISTRY.getId(typeKey); }
|
||||
|
||||
/**
|
||||
* Gets the "attacker" of the damage.
|
||||
* This is the indirect cause of the damage, like the shooter of a projectile, or null if there was none.
|
||||
|
Loading…
Reference in New Issue
Block a user