Package com.flansmod.common.network

Source Code of com.flansmod.common.network.PacketPlaneControl

package com.flansmod.common.network;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

import com.flansmod.common.driveables.EntityDriveable;
import com.flansmod.common.driveables.EntityPlane;

public class PacketPlaneControl extends PacketDriveableControl
{
  public boolean gear, doors, wings;

  public PacketPlaneControl() {}

  public PacketPlaneControl(EntityDriveable driveable)
  {
    super(driveable);
    EntityPlane plane = (EntityPlane)driveable;
    gear = plane.varGear;
    doors = plane.varDoor;
    wings = plane.varWing;
  }
 
  @Override
  public void encodeInto(ChannelHandlerContext ctx, ByteBuf data)
  {
      super.encodeInto(ctx, data);
      data.writeBoolean(gear);
      data.writeBoolean(doors);
      data.writeBoolean(wings);
  }

  @Override
  public void decodeInto(ChannelHandlerContext ctx, ByteBuf data)
  {
    super.decodeInto(ctx, data);
    gear = data.readBoolean();
    doors = data.readBoolean();
    wings = data.readBoolean();
  }
 
  @Override
  protected void updateDriveable(EntityDriveable driveable, boolean clientSide)
  {
    super.updateDriveable(driveable, clientSide);
    EntityPlane plane = (EntityPlane)driveable;
    plane.varDoor = doors;
    plane.varGear = gear;
    plane.varWing = wings;
  }
}
TOP

Related Classes of com.flansmod.common.network.PacketPlaneControl

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.