Search in sources :

Example 11 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class AnimateEntityMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(AnimateEntityMessage packet) {
    AnimatePacket pkAnimate = new AnimatePacket();
    pkAnimate.eid = packet.id;
    //(msgAnimate.animation & 0xFF);
    pkAnimate.action = (byte) 0x01;
    return new PEPacket[] { pkAnimate };
}
Also used : AnimatePacket(org.dragonet.net.packet.minecraft.AnimatePacket) PEPacket(org.dragonet.net.packet.minecraft.PEPacket)

Example 12 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class BlockChangeMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(BlockChangeMessage packet) {
    UpdateBlockPacket pkBC = new UpdateBlockPacket();
    UpdateBlockPacket.UpdateBlockRecord rec = new UpdateBlockPacket.UpdateBlockRecord();
    rec.x = packet.x;
    rec.z = packet.z;
    rec.y = (byte) (packet.y & 0xFF);
    rec.block = (byte) (this.getTranslator().getItemTranslator().translateToPE(packet.type >> 4) & 0xFF);
    rec.meta = UpdateBlockPacket.FLAG_ALL;
    pkBC.records = new UpdateBlockPacket.UpdateBlockRecord[] { rec };
    return new PEPacket[] { pkBC };
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket) UpdateBlockPacket(org.dragonet.net.packet.minecraft.UpdateBlockPacket)

Example 13 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class ChatMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(ChatMessage packet) {
    String msg = "";
    try {
        //String msg = ((ChatMessage) message).text.asPlaintext();
        Object json = new JSONParser().parse(packet.text.encode());
        if (json instanceof JSONObject) {
            msg = this.getTranslator().translateChatMessage((JSONObject) json);
        } else {
            msg = packet.text.asPlaintext();
        }
    } catch (ParseException ex) {
        return null;
    }
    //if(json)
    ChatPacket pkMessage = new ChatPacket();
    pkMessage.source = "";
    pkMessage.type = ChatPacket.TextType.RAW;
    pkMessage.message = msg;
    return new PEPacket[] { pkMessage };
}
Also used : ChatPacket(org.dragonet.net.packet.minecraft.ChatPacket) JSONObject(org.json.simple.JSONObject) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) ParseException(org.json.simple.parser.ParseException)

Example 14 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class PENetworkClient method processPacketBuffer.

public void processPacketBuffer(byte[] buffer) {
    PEPacket packet = Protocol.decode(buffer);
    if (packet == null) {
        return;
    }
    handlePacket(packet);
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket)

Example 15 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class PlayerPositionMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(PlayerPositionMessage packet) {
    MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
    pkMovePlayer.eid = this.getSession().getPlayer().getEntityId();
    pkMovePlayer.x = (float) packet.x;
    pkMovePlayer.y = (float) packet.y;
    pkMovePlayer.z = (float) packet.z;
    pkMovePlayer.yaw = this.getSession().getPlayer().getLocation().getYaw();
    pkMovePlayer.pitch = this.getSession().getPlayer().getLocation().getPitch();
    pkMovePlayer.teleport = true;
    return new PEPacket[] { pkMovePlayer };
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket) MovePlayerPacket(org.dragonet.net.packet.minecraft.MovePlayerPacket)

Aggregations

PEPacket (org.dragonet.net.packet.minecraft.PEPacket)22 MovePlayerPacket (org.dragonet.net.packet.minecraft.MovePlayerPacket)4 GlowPlayer (net.glowstone.entity.GlowPlayer)3 PEInventorySlot (org.dragonet.inventory.PEInventorySlot)3 Entity (org.bukkit.entity.Entity)2 MoveEntitiesPacket (org.dragonet.net.packet.minecraft.MoveEntitiesPacket)2 PlayerListPacket (org.dragonet.net.packet.minecraft.PlayerListPacket)2 UpdateBlockPacket (org.dragonet.net.packet.minecraft.UpdateBlockPacket)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 PlayerProfile (net.glowstone.entity.meta.profile.PlayerProfile)1 SpawnObjectMessage (net.glowstone.net.message.play.entity.SpawnObjectMessage)1 BlockChangeMessage (net.glowstone.net.message.play.game.BlockChangeMessage)1 MultiBlockChangeMessage (net.glowstone.net.message.play.game.MultiBlockChangeMessage)1 CloseWindowMessage (net.glowstone.net.message.play.inv.CloseWindowMessage)1 Player (org.bukkit.entity.Player)1 PocketPotionEffect (org.dragonet.PocketPotionEffect)1 AddItemEntityPacket (org.dragonet.net.packet.minecraft.AddItemEntityPacket)1 AddPlayerPacket (org.dragonet.net.packet.minecraft.AddPlayerPacket)1 AnimatePacket (org.dragonet.net.packet.minecraft.AnimatePacket)1