Search in sources :

Example 6 with Packet

use of ejip123.Packet in project Citizens2 by CitizensDev.

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt())
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[navigating ? EnumItemSlot.values().length : EnumItemSlot.values().length + 1];
    if (!navigating) {
        packets[5] = new PacketPlayOutEntityHeadRotation(this, (byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
    }
    int i = 0;
    for (EnumItemSlot slot : EnumItemSlot.values()) {
        packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_11_R1.Packet) EnumItemSlot(net.minecraft.server.v1_11_R1.EnumItemSlot) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_11_R1.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityEquipment(net.minecraft.server.v1_11_R1.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 7 with Packet

use of ejip123.Packet in project Citizens2 by CitizensDev.

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt())
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[navigating ? this.inventory.armor.length : this.inventory.armor.length + 1];
    if (!navigating) {
        packets[this.inventory.armor.length] = new PacketPlayOutEntityHeadRotation(this, (byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
    }
    for (int i = 0; i < this.inventory.armor.length; i++) {
        packets[i] = new PacketPlayOutEntityEquipment(getId(), i, getEquipment(i));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_8_R3.Packet) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityEquipment(net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 8 with Packet

use of ejip123.Packet in project jop by jop-devel.

the class Server method request.

public void request(Packet receivedPacket, int offset) {
    StringBuffer receiveBuffer = new StringBuffer(receivedPacket.len());
    int bufferLength = receivedPacket.getData(offset, receiveBuffer);
    String buffer = receiveBuffer.toString();
    byte[] receivedData = buffer.getBytes();
    Call rpcCall = new Call();
    rpcCall.read(receivedData);
    Handler handler = Handler.create(rpcCall);
    Reply reply = handler.read();
    StringBuffer portBuffer = new StringBuffer(22);
    receivedPacket.getData(0, portBuffer);
    int destinationPort = ((int) portBuffer.charAt(20) << 8) | ((int) portBuffer.charAt(21));
    destIp = Ip.Ip(192, 168, 1, 1);
    srcIp = Ip.Ip(192, 168, 1, 2);
    srcPort = 111;
    Dbg.wr(rpcCall.toString() + "\nHandler:" + reply.getData().length + "----");
    Dbg.lf();
    if (reply != null) {
        idx = Udp.OFFSET << 2;
        p = PacketPool.getFreshPacket();
        p.setLen(reply.getWriteOffset() + idx);
        byte[] Data = reply.getData();
        for (int i = 0; i < reply.getWriteOffset(); i++) {
            System.out.println("[" + i + "]=" + Data[i] + "; ");
            p.setByte(Data[i] & 0xFF, idx + i);
        }
        Udp.send(p, srcIp, destIp, srcPort, destinationPort, true);
    }
    String data;
    try {
        data = new String(receivedData, 0, bufferLength);
    } catch (Exception e) {
        data = "null";
    }
    if (data.startsWith("exit"))
        serverRunning = false;
    receivedPacket.free();
}
Also used : Call(ninjaFS.Rpc.Call) UdpHandler(ejip123.UdpHandler) Handler(ninjaFS.Rpc.Handler) Reply(ninjaFS.Rpc.Reply)

Example 9 with Packet

use of ejip123.Packet in project jop by jop-devel.

the class Server method main.

public static void main(String[] args) {
    // inits 10 packet buffers with 1500B each
    PacketPool.init(10, 1500);
    Serial ser;
    if (TWO_SERIAL) {
        // serial debug output		
        Dbg.initSer();
        // simulator
        ser = new Serial(10, 1000, Const.IO_UART_BG_MODEM_BASE);
    } else {
        // sends debug output over the network to 192.168.2.1:10000 (see init method)		
        DbgUdp.init();
        // one byte every ~400us at 19200 baud
        ser = new Serial(10, 1000, Const.IO_UART1_BASE);
    }
    // initializes a routing table with 3 routes
    Router.init(3);
    LinkLayer slip = Slip.init(9, 10000, ser, Ip.Ip(192, 168, 1, 2), 1500);
    // ip (and therefore icmp and tcp) loop thread: period 50ms
    Ip.init(6, 50000);
    Router.addRoute(new Route(Ip.Ip(192, 168, 2, 0), Ip.Ip(255, 255, 255, 0), slip));
    // where should packets go which are not matched by a route?
    Router.setDefaultInterface(slip);
    Dbg.wr("Starting Mission");
    Dbg.lf();
    RtThread.startMission();
    Router.print();
    Dbg.wr("Starting Server");
    Dbg.lf();
    Server server = new Server();
    server.run();
}
Also used : Serial(ejip123.util.Serial)

Example 10 with Packet

use of ejip123.Packet in project jop by jop-devel.

the class HelloWorldHereIPing method main.

public static void main(String[] args) {
    // inits 10 packet buffers with 1500B each
    PacketPool.init(10, 1500);
    Serial ser;
    if (TWO_SERIAL) {
        // serial debug output		
        Dbg.initSer();
        // simulator
        ser = new Serial(10, 1000, Const.IO_UART_BG_MODEM_BASE);
    } else {
        // sends debug output over the network to 192.168.2.1:10000 (see init method)		
        DbgUdp.init();
        // one byte every ~400us at 19200 baud
        ser = new Serial(10, 1000, Const.IO_UART1_BASE);
    }
    // initializes a routing table with 3 routes
    Router.init(3);
    LinkLayer slip = Slip.init(9, 10000, ser, Ip.Ip(192, 168, 1, 2), 1500);
    // ip (and therefore icmp and tcp) loop thread: period 50ms
    Ip.init(6, 50000);
    Router.addRoute(new Route(Ip.Ip(192, 168, 2, 0), Ip.Ip(255, 255, 255, 0), slip));
    // where should packets go which are not matched by a route?
    Router.setDefaultInterface(slip);
    RtThread.startMission();
    Router.print();
    forever();
}
Also used : Serial(ejip123.util.Serial)

Aggregations

Packet (com.yahoo.fs4.Packet)4 Location (org.bukkit.Location)4 BasicPacket (com.yahoo.fs4.BasicPacket)3 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)3 QueryPacket (com.yahoo.fs4.QueryPacket)3 Packet (ejip123.Packet)3 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)2 PingPacket (com.yahoo.fs4.PingPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)2 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)2 Result (com.yahoo.search.Result)2 Serial (ejip123.util.Serial)2 IOException (java.io.IOException)2 CompressionType (com.yahoo.compress.CompressionType)1 IdString (com.yahoo.document.idstring.IdString)1 ParseException (com.yahoo.document.select.parser.ParseException)1 TokenMgrError (com.yahoo.document.select.parser.TokenMgrError)1 DocsumPacket (com.yahoo.fs4.DocsumPacket)1 FS4Channel (com.yahoo.fs4.mplex.FS4Channel)1