Search in sources :

Example 6 with PEPacket

use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.

the class PCUpdateTileEntityPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerUpdateTileEntityPacket packet) {
    BlockEntityDataPacket data = new BlockEntityDataPacket();
    data.blockPosition = new BlockPosition(packet.getPosition());
    data.tag = ItemBlockTranslator.translateBlockEntityToPE(packet.getNBT());
    return new PEPacket[] { data };
}
Also used : BlockPosition(org.dragonet.common.maths.BlockPosition) PEPacket(org.dragonet.protocol.PEPacket) BlockEntityDataPacket(org.dragonet.protocol.packets.BlockEntityDataPacket)

Example 7 with PEPacket

use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.

the class PCAnimationPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityAnimationPacket packet) {
    CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
    if (entity == null) {
        return null;
    }
    AnimatePacket pk = new AnimatePacket();
    switch(packet.getAnimation()) {
        case CRITICAL_HIT:
            pk.action = AnimatePacket.ACTION_CRITICAL_HIT;
            break;
        case DAMAGE:
            break;
        case EAT_FOOD:
            break;
        case ENCHANTMENT_CRITICAL_HIT:
            break;
        case LEAVE_BED:
            pk.action = AnimatePacket.ANIMATION_LEAVE_BED;
            break;
        case SWING_ARM:
            pk.action = AnimatePacket.ANIMATION_SWING_ARM;
    }
    pk.eid = entity.proxyEid;
    return new PEPacket[] { pk };
}
Also used : CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) AnimatePacket(org.dragonet.protocol.packets.AnimatePacket) PEPacket(org.dragonet.protocol.PEPacket)

Example 8 with PEPacket

use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.

the class PCEntityRotationPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityRotationPacket packet) {
    CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
    if (entity == null) {
        if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
            entity = session.getEntityCache().getClientEntity();
        } else {
            return null;
        }
    }
    entity.relativeMove(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ(), packet.getYaw(), packet.getPitch());
    if (entity.shouldMove) {
        MoveEntityPacket pk = new MoveEntityPacket();
        pk.rtid = entity.proxyEid;
        pk.yaw = (byte) (entity.yaw / (360d / 256d));
        pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
        pk.pitch = (byte) (entity.pitch / (360d / 256d));
        pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
        pk.onGround = packet.isOnGround();
        entity.shouldMove = false;
        return new PEPacket[] { pk };
    }
    return null;
}
Also used : CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) Vector3F(org.dragonet.common.maths.Vector3F) PEPacket(org.dragonet.protocol.PEPacket) MoveEntityPacket(org.dragonet.protocol.packets.MoveEntityPacket)

Example 9 with PEPacket

use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.

the class PCSetTitlePacketTranslator method translate.

@Override
public PEPacket[] translate(UpstreamSession session, ServerTitlePacket packet) {
    SetTitlePacket titlePacket = new SetTitlePacket();
    switch(packet.getAction()) {
        case ACTION_BAR:
            titlePacket.action = SetTitlePacket.SET_ACTIONBAR;
            titlePacket.text = packet.getActionBar().getFullText();
            break;
        case TITLE:
            titlePacket.action = SetTitlePacket.SET_TITLE;
            titlePacket.text = packet.getTitle().getText();
            break;
        case SUBTITLE:
            titlePacket.action = SetTitlePacket.SET_SUBTITLE;
            titlePacket.text = packet.getSubtitle().getText();
            break;
        case RESET:
        case CLEAR:
            titlePacket.action = SetTitlePacket.RESET;
            titlePacket.text = "";
            break;
        default:
            return null;
    }
    titlePacket.fadeIn = packet.getFadeIn();
    titlePacket.fadeOut = packet.getFadeOut();
    titlePacket.stay = packet.getStay();
    return new PEPacket[] { titlePacket };
}
Also used : PEPacket(org.dragonet.protocol.PEPacket) SetTitlePacket(org.dragonet.protocol.packets.SetTitlePacket)

Example 10 with PEPacket

use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.

the class PCDestroyEntitiesPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityDestroyPacket packet) {
    PEPacket[] ret = new PEPacket[packet.getEntityIds().length];
    for (int i = 0; i < ret.length; i++) {
        CachedEntity e = session.getEntityCache().removeByRemoteEID(packet.getEntityIds()[i]);
        if (e == null) {
            continue;
        }
        ret[i] = new RemoveEntityPacket();
        ((RemoveEntityPacket) ret[i]).eid = e.proxyEid;
    }
    return ret;
}
Also used : RemoveEntityPacket(org.dragonet.protocol.packets.RemoveEntityPacket) CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) PEPacket(org.dragonet.protocol.PEPacket)

Aggregations

PEPacket (org.dragonet.protocol.PEPacket)28 CachedEntity (org.dragonet.proxy.network.cache.CachedEntity)14 Vector3F (org.dragonet.common.maths.Vector3F)8 MoveEntityPacket (org.dragonet.protocol.packets.MoveEntityPacket)5 BlockPosition (org.dragonet.common.maths.BlockPosition)4 UpdateAttributesPacket (org.dragonet.protocol.packets.UpdateAttributesPacket)3 MobEffectPacket (org.dragonet.protocol.packets.MobEffectPacket)2 Timing (co.aikar.timings.Timing)1 PlayerListEntry (com.github.steveice10.mc.protocol.data.game.PlayerListEntry)1 Attribute (com.github.steveice10.mc.protocol.data.game.entity.attribute.Attribute)1 GameMode (com.github.steveice10.mc.protocol.data.game.entity.player.GameMode)1 ExplodedBlockRecord (com.github.steveice10.mc.protocol.data.game.world.block.ExplodedBlockRecord)1 BuiltinSound (com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound)1 TranslationMessage (com.github.steveice10.mc.protocol.data.message.TranslationMessage)1 ServerPlaySoundPacket (com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlaySoundPacket)1 JsonParseException (com.google.gson.JsonParseException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 PocketPotionEffect (org.dragonet.common.data.PocketPotionEffect)1 PEEntityAttribute (org.dragonet.common.data.entity.PEEntityAttribute)1