Package logisticspipes.network.packets.pipe

Source Code of logisticspipes.network.packets.pipe.RoutingLaserPacket

package logisticspipes.network.packets.pipe;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import logisticspipes.network.LPDataInputStream;
import logisticspipes.network.LPDataOutputStream;
import logisticspipes.network.abstractpackets.ModernPacket;
import logisticspipes.renderer.LogisticsHUDRenderer;
import logisticspipes.routing.LaserData;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.minecraft.entity.player.EntityPlayer;

@Accessors(chain=true)
public class RoutingLaserPacket extends ModernPacket {

  @Setter
  @Getter
  List<LaserData> lasers = new ArrayList<LaserData>();
 
  public RoutingLaserPacket(int id) {
    super(id);
  }

  @Override
  public void readData(LPDataInputStream data) throws IOException {
    while(data.readBoolean()) {
      lasers.add(new LaserData().readData(data));
    }
  }
 
  @Override
  public void processPacket(EntityPlayer player) {
    LogisticsHUDRenderer.instance().setLasers(getLasers());
  }

  @Override
  public void writeData(LPDataOutputStream data) throws IOException {
    for(LaserData laser:lasers) {
      data.writeBoolean(true);
      laser.writeData(data);
    }
    data.writeBoolean(false);
  }
 
  @Override
  public ModernPacket template() {
    return new RoutingLaserPacket(getId());
  }
 
}
TOP

Related Classes of logisticspipes.network.packets.pipe.RoutingLaserPacket

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.