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 aos) {
        this.id = aos.getId();
        this.x = aos.getX();
        this.y = aos.getY();
        this.z = aos.getZ();
        this.value = aos.getValue();
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.id = mg.readVarInt();
        this.x = mg.readDouble();
        this.y = mg.readDouble();
        this.z = mg.readDouble();
        this.value = mg.readShort();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(this.id);
        mg.writeDouble(this.x);
        mg.writeDouble(this.y);
        mg.writeDouble(this.z);
        mg.writeShort(this.value);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.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;
    }
}
