Package logisticspipes.network.packets.block

Source Code of logisticspipes.network.packets.block.SecurityStationCC

package logisticspipes.network.packets.block;

import logisticspipes.blocks.LogisticsSecurityTileEntity;
import logisticspipes.gui.GuiSecurityStation;
import logisticspipes.network.abstractpackets.IntegerCoordinatesPacket;
import logisticspipes.network.abstractpackets.ModernPacket;
import logisticspipes.proxy.MainProxy;
import lombok.experimental.Accessors;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@Accessors(chain=true)
public class SecurityStationCC extends IntegerCoordinatesPacket {

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

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

  @Override
  public void processPacket(EntityPlayer player) {
    LogisticsSecurityTileEntity tile = this.getTile(player.worldObj, LogisticsSecurityTileEntity.class);
    if(tile instanceof LogisticsSecurityTileEntity) {
      if(MainProxy.isClient(player.worldObj)) {
        tile.setClientCC(getInteger() == 1);
        handleClientSide(player);
      } else {
        tile.changeCC();
      }
    }
  }
 
  @SideOnly(Side.CLIENT)
  private void handleClientSide(EntityPlayer player) {
    if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiSecurityStation) {
      ((GuiSecurityStation)FMLClientHandler.instance().getClient().currentScreen).refreshCheckBoxes();
    }
  }
}
TOP

Related Classes of logisticspipes.network.packets.block.SecurityStationCC

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.