package common.packet;

import java.io.IOException;

import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.util.BlockPos;
import common.world.World;

public class S33PacketUpdateSign implements Packet<IClientPlayer>
{
    private World world;
    private BlockPos blockPos;
    private String[] lines;
//    private String command;

    public S33PacketUpdateSign()
    {
    }

    public S33PacketUpdateSign(World worldIn, BlockPos blockPosIn, String[] linesIn)
    {
        this.world = worldIn;
        this.blockPos = blockPosIn;
        this.lines = new String[] {linesIn[0], linesIn[1], linesIn[2], linesIn[3]};
//        this.command = commandIn != null && commandIn.isEmpty() ? null : commandIn;
    }

    /**
     * Reads the raw packet data from the data stream.
     */
    public void readPacketData(PacketBuffer buf) throws IOException
    {
        this.blockPos = buf.readBlockPos();
        this.lines = new String[4];

        for (int i = 0; i < 4; ++i)
        {
            this.lines[i] = buf.readStringFromBuffer(64);
        }
        
//        this.command = buf.readStringFromBuffer(1024);
//        this.command = this.command.isEmpty() ? null : this.command;
    }

    /**
     * Writes the raw packet data to the data stream.
     */
    public void writePacketData(PacketBuffer buf) throws IOException
    {
        buf.writeBlockPos(this.blockPos);

        for (int i = 0; i < 4; ++i)
        {
            buf.writeString(this.lines[i]);
        }
        
//        buf.writeString(this.command == null ? "" : this.command);
    }

    /**
     * Passes this Packet on to the NetHandler for processing.
     */
    public void processPacket(IClientPlayer handler)
    {
        handler.handleUpdateSign(this);
    }

    public BlockPos getPos()
    {
        return this.blockPos;
    }

    public String[] getLines()
    {
        return this.lines;
    }

//    public String getCommand()
//    {
//        return this.command;
//    }
}
