    001package net.minecraft.network.packet;
    002
    003import java.io.DataInputStream;
    004import java.io.DataOutputStream;
    005import java.io.IOException;
    006
    007public class Packet8UpdateHealth extends Packet
    008{
    009    /** Variable used for incoming health packets */
    010    public int healthMP;
    011    public int food;
    012
    013    /**
    014     * Players logging on get a saturation of 5.0. Eating food increases the saturation as well as the food bar.
    015     */
    016    public float foodSaturation;
    017
    018    public Packet8UpdateHealth() {}
    019
    020    public Packet8UpdateHealth(int par1, int par2, float par3)
    021    {
    022        this.healthMP = par1;
    023        this.food = par2;
    024        this.foodSaturation = par3;
    025    }
    026
    027    /**
    028     * Abstract. Reads the raw packet data from the data stream.
    029     */
    030    public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    031    {
    032        this.healthMP = par1DataInputStream.readShort();
    033        this.food = par1DataInputStream.readShort();
    034        this.foodSaturation = par1DataInputStream.readFloat();
    035    }
    036
    037    /**
    038     * Abstract. Writes the raw packet data to the data stream.
    039     */
    040    public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    041    {
    042        par1DataOutputStream.writeShort(this.healthMP);
    043        par1DataOutputStream.writeShort(this.food);
    044        par1DataOutputStream.writeFloat(this.foodSaturation);
    045    }
    046
    047    /**
    048     * Passes this Packet on to the NetHandler for processing.
    049     */
    050    public void processPacket(NetHandler par1NetHandler)
    051    {
    052        par1NetHandler.handleUpdateHealth(this);
    053    }
    054
    055    /**
    056     * Abstract. Return the size of the packet (not counting the header).
    057     */
    058    public int getPacketSize()
    059    {
    060        return 8;
    061    }
    062
    063    /**
    064     * only false for the abstract Packet class, all real packets return true
    065     */
    066    public boolean isRealPacket()
    067    {
    068        return true;
    069    }
    070
    071    /**
    072     * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    073     * class
    074     */
    075    public boolean containsSameEntityIDAs(Packet par1Packet)
    076    {
    077        return true;
    078    }
    079}