Archived
0

UpdateHealthPacket

This commit is contained in:
2021-05-08 23:01:03 +03:00
parent c6669af651
commit f0f29e2d56
3 changed files with 64 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ public enum State {
JoinGamePacket.class, 0x23,
PlayerAbilitiesPacket.class,0x2C,
SPlayerPositionAndLookPacket.class, 0x2F,
UpdateHealthPacket.class, 0x41,
SpawnPositionPacket.class, 0x46
)
);

View File

@@ -0,0 +1,35 @@
package mc.protocol.packets.server;
import lombok.Data;
import mc.protocol.io.NetByteBuf;
import mc.protocol.packets.ServerSidePacket;
/**
* Update Health Packet.
*
* <p>Структура пакета</p>
* <pre>
* | FIELD | TYPE | NOTES |
* |-----------------|--------|----------------------------------|
* | Health | Float | 0 = смерть; 20 = полное здоровье |
* | Food | VarInt | 0-20 |
* | Food Saturation | Float | 0-5 |
* </pre>
*
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Update_Health">Update Health</a>
* @see <a href="https://minecraft.fandom.com/wiki/Food#Hunger_and_saturation">Food: Hunger and saturation</a>
*/
@Data
public class UpdateHealthPacket implements ServerSidePacket {
private float health;
private int food;
private float foodSaturation;
@Override
public void writeSelf(NetByteBuf netByteBuf) {
netByteBuf.writeFloat(this.health);
netByteBuf.writeVarInt(this.food);
netByteBuf.writeFloat(this.foodSaturation);
}
}