package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.network.protocol.Packet;

public class ClientboundAddExperienceOrbPacket implements Packet<ClientGamePacketListener> {
    private int id;
    private double x;
    private double y;
    private double z;
    private int value;
    
    public ClientboundAddExperienceOrbPacket() {
    }
    
    public ClientboundAddExperienceOrbPacket(final ExperienceOrb akw) {
        this.id = akw.getId();
        this.x = akw.getX();
        this.y = akw.getY();
        this.z = akw.getZ();
        this.value = akw.getValue();
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.id = kv.readVarInt();
        this.x = kv.readDouble();
        this.y = kv.readDouble();
        this.z = kv.readDouble();
        this.value = kv.readShort();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.id);
        kv.writeDouble(this.x);
        kv.writeDouble(this.y);
        kv.writeDouble(this.z);
        kv.writeShort(this.value);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleAddExperienceOrb(this);
    }
    
    public int getId() {
        return this.id;
    }
    
    public double getX() {
        return this.x;
    }
    
    public double getY() {
        return this.y;
    }
    
    public double getZ() {
        return this.z;
    }
    
    public int getValue() {
        return this.value;
    }
}
