Search in sources :

Example 1 with RespawnPacket

use of org.dragonet.net.packet.minecraft.RespawnPacket in project Dragonet-Legacy by DragonetMC.

the class HealthMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(HealthMessage packet) {
    int h = (int) packet.health;
    if (h <= 0) {
        //DEAD
        SetHealthPacket pk1 = new SetHealthPacket(h);
        RespawnPacket pk2 = new RespawnPacket();
        pk2.x = (float) getTranslator().getSession().getServer().getWorlds().get(0).getSpawnLocation().getX();
        pk2.y = (float) getTranslator().getSession().getServer().getWorlds().get(0).getSpawnLocation().getY();
        pk2.z = (float) getTranslator().getSession().getServer().getWorlds().get(0).getSpawnLocation().getZ();
        return new PEPacket[] { pk1, pk2 };
    } else {
        SetHealthPacket pk = new SetHealthPacket(h);
        return new PEPacket[] { pk };
    }
}
Also used : SetHealthPacket(org.dragonet.net.packet.minecraft.SetHealthPacket) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) RespawnPacket(org.dragonet.net.packet.minecraft.RespawnPacket)

Aggregations

PEPacket (org.dragonet.net.packet.minecraft.PEPacket)1 RespawnPacket (org.dragonet.net.packet.minecraft.RespawnPacket)1 SetHealthPacket (org.dragonet.net.packet.minecraft.SetHealthPacket)1