Package logisticspipes.network.packets.satpipe

Source Code of logisticspipes.network.packets.satpipe.SatPipeSetID

package logisticspipes.network.packets.satpipe;

import java.io.IOException;

import logisticspipes.network.LPDataInputStream;
import logisticspipes.network.LPDataOutputStream;
import logisticspipes.network.abstractpackets.CoordinatesPacket;
import logisticspipes.network.abstractpackets.ModernPacket;
import logisticspipes.pipes.PipeFluidSatellite;
import logisticspipes.pipes.PipeItemsSatelliteLogistics;
import logisticspipes.pipes.basic.LogisticsTileGenericPipe;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.minecraft.entity.player.EntityPlayer;

@Accessors(chain = true)
public class SatPipeSetID extends CoordinatesPacket {

  public SatPipeSetID(int id) {
    super(id);
  }

  @Override
  public ModernPacket template() {
    return new SatPipeSetID(getId());
  }

  @Getter
  @Setter
  private int satID;

  @Override
  public void writeData(LPDataOutputStream data) throws IOException {
    data.writeInt(satID);
    super.writeData(data);
  }

  @Override
  public void readData(LPDataInputStream data) throws IOException {
    satID = data.readInt();
    super.readData(data);
  }

  @Override
  public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = getPipe(player.worldObj);
    if (pipe == null) {
      return;
    }

    if (pipe.pipe instanceof PipeItemsSatelliteLogistics) {
      ((PipeItemsSatelliteLogistics) pipe.pipe).setSatelliteId(getSatID());
    }
    if (pipe.pipe instanceof PipeFluidSatellite) {
      ((PipeFluidSatellite) pipe.pipe)
          .setSatelliteId(getSatID());
    }
  }

}
TOP

Related Classes of logisticspipes.network.packets.satpipe.SatPipeSetID

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.