Search in sources :

Example 6 with Vector3F

use of org.dragonet.common.maths.Vector3F in project DragonProxy by DragonetMC.

the class PCEntityVelocityPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityVelocityPacket 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.motionX = packet.getMotionX();
    entity.motionY = packet.getMotionY();
    entity.motionZ = packet.getMotionZ();
    SetEntityMotionPacket pk = new SetEntityMotionPacket();
    pk.rtid = entity.proxyEid;
    pk.motion = new Vector3F((float) packet.getMotionX(), (float) packet.getMotionY(), (float) packet.getMotionZ());
    return new PEPacket[] { pk };
}
Also used : SetEntityMotionPacket(org.dragonet.protocol.packets.SetEntityMotionPacket) CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) Vector3F(org.dragonet.common.maths.Vector3F) PEPacket(org.dragonet.protocol.PEPacket)

Example 7 with Vector3F

use of org.dragonet.common.maths.Vector3F in project DragonProxy by DragonetMC.

the class PCEntityTeleportPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityTeleportPacket 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.absoluteMove(packet.getX(), packet.getY(), packet.getZ(), 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 8 with Vector3F

use of org.dragonet.common.maths.Vector3F in project DragonProxy by DragonetMC.

the class PCExplosionTranslator method translate.

@Override
public PEPacket[] translate(UpstreamSession session, ServerExplosionPacket packet) {
    ExplodePacket pk = new ExplodePacket();
    pk.position = new Vector3F(packet.getX(), packet.getY(), packet.getZ());
    pk.radius = packet.getRadius();
    pk.destroyedBlocks = new ArrayList<>(packet.getExploded().size());
    for (ExplodedBlockRecord record : packet.getExploded()) pk.destroyedBlocks.add(new BlockPosition(record.getX(), record.getY(), record.getZ()));
    return new PEPacket[] { pk };
}
Also used : ExplodedBlockRecord(com.github.steveice10.mc.protocol.data.game.world.block.ExplodedBlockRecord) Vector3F(org.dragonet.common.maths.Vector3F) BlockPosition(org.dragonet.common.maths.BlockPosition) PEPacket(org.dragonet.protocol.PEPacket) ExplodePacket(org.dragonet.protocol.packets.ExplodePacket)

Example 9 with Vector3F

use of org.dragonet.common.maths.Vector3F in project DragonProxy by DragonetMC.

the class PCSoundEventPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerPlayBuiltinSoundPacket packet) {
    LevelSoundEventPacket pk = new LevelSoundEventPacket();
    // System.out.println("BuiltIn Sound packet: " + packet.getSound().name());
    pk.position = new Vector3F((float) packet.getX(), (float) packet.getY(), (float) packet.getZ());
    switch(packet.getSound()) {
        case BLOCK_CHEST_OPEN:
            pk.sound = LevelSoundEventPacket.Sound.CHEST_OPEN;
            break;
        case BLOCK_CHEST_CLOSE:
            pk.sound = LevelSoundEventPacket.Sound.CHEST_CLOSED;
            break;
        case BLOCK_SHULKER_BOX_OPEN:
            pk.sound = LevelSoundEventPacket.Sound.SHULKER_BOX_OPEN;
            break;
        case BLOCK_SHULKER_BOX_CLOSE:
            pk.sound = LevelSoundEventPacket.Sound.SHULKER_BOX_CLOSE;
            break;
        case ENCHANT_THORNS_HIT:
            pk.sound = LevelSoundEventPacket.Sound.THORNS;
            break;
        case ENTITY_ARROW_SHOOT:
            pk.sound = LevelSoundEventPacket.Sound.SHOOT;
            break;
        case ENTITY_ARROW_HIT_PLAYER:
            pk.sound = LevelSoundEventPacket.Sound.HIT;
            break;
        case ENTITY_ARROW_HIT:
            pk.sound = LevelSoundEventPacket.Sound.BOW_HIT;
            break;
        case ENTITY_GENERIC_EXTINGUISH_FIRE:
        case BLOCK_FIRE_EXTINGUISH:
            pk.sound = LevelSoundEventPacket.Sound.EXTINGUISH_FIRE;
            break;
        case ENTITY_CAT_PURR:
            pk.sound = LevelSoundEventPacket.Sound.PURR;
            break;
        case ENTITY_CAT_PURREOW:
            pk.sound = LevelSoundEventPacket.Sound.PURREOW;
            break;
        case ENTITY_HORSE_GALLOP:
            pk.sound = LevelSoundEventPacket.Sound.GALLOP;
            break;
        case ENTITY_LIGHTNING_THUNDER:
            pk.sound = LevelSoundEventPacket.Sound.THUNDER;
            break;
        case ENTITY_PLAYER_LEVELUP:
            pk.sound = LevelSoundEventPacket.Sound.LEVEL_UP;
            break;
        case ENTITY_LEASHKNOT_PLACE:
            pk.sound = LevelSoundEventPacket.Sound.LEASHKNOT_PLACE;
            break;
        case ENTITY_LEASHKNOT_BREAK:
            pk.sound = LevelSoundEventPacket.Sound.LEASHKNOT_BREAK;
            break;
        case ENTITY_SHULKER_OPEN:
            pk.sound = LevelSoundEventPacket.Sound.SHULKER_OPEN;
            break;
        case ENTITY_SHULKER_CLOSE:
            pk.sound = LevelSoundEventPacket.Sound.SHULKER_CLOSE;
            break;
        case ITEM_BOTTLE_FILL_DRAGONBREATH:
            pk.sound = LevelSoundEventPacket.Sound.BOTTLE_DRAGON_BREATH;
            break;
        case ITEM_BUCKET_FILL_LAVA:
            pk.sound = LevelSoundEventPacket.Sound.BUCKET_FILL_LAVA;
            break;
        case ITEM_BUCKET_EMPTY_LAVA:
            pk.sound = LevelSoundEventPacket.Sound.BUCKET_EMPTY_LAVA;
            break;
        case ITEM_BUCKET_FILL:
            pk.sound = LevelSoundEventPacket.Sound.BUCKET_FILL_WATER;
            break;
        case ITEM_BUCKET_EMPTY:
            pk.sound = LevelSoundEventPacket.Sound.BUCKET_EMPTY_WATER;
            break;
        case RECORD_11:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_11;
            break;
        case RECORD_13:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_13;
            break;
        case RECORD_BLOCKS:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_BLOCKS;
            break;
        case RECORD_CAT:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_CAT;
            break;
        case RECORD_CHIRP:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_CHIRP;
            break;
        case RECORD_FAR:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_FAR;
            break;
        case RECORD_MALL:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_MALL;
            break;
        case RECORD_MELLOHI:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_MELLOHI;
            break;
        case RECORD_STAL:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_STAL;
            break;
        case RECORD_STRAD:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_STRAD;
            break;
        case RECORD_WAIT:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_WAIT;
            break;
        case RECORD_WARD:
            pk.sound = LevelSoundEventPacket.Sound.RECORD_WARD;
            break;
        case ENTITY_ZOMBIE_VILLAGER_CONVERTED:
            pk.sound = LevelSoundEventPacket.Sound.UNFECT;
            break;
        case ENTITY_ZOMBIE_VILLAGER_CURE:
            pk.sound = LevelSoundEventPacket.Sound.REMEDY;
            break;
        case ENTITY_SHEEP_SHEAR:
        case ENTITY_MOOSHROOM_SHEAR:
            pk.sound = LevelSoundEventPacket.Sound.SHEAR;
            break;
        case BLOCK_GRASS_BREAK:
        case BLOCK_ANVIL_BREAK:
        case BLOCK_GLASS_BREAK:
        case BLOCK_CLOTH_BREAK:
        case BLOCK_GRAVEL_BREAK:
        case BLOCK_LADDER_BREAK:
        case BLOCK_METAL_BREAK:
        case BLOCK_SAND_BREAK:
        case BLOCK_SLIME_BREAK:
        case BLOCK_SNOW_BREAK:
        case BLOCK_STONE_BREAK:
        case BLOCK_WOOD_BREAK:
            pk.sound = LevelSoundEventPacket.Sound.BREAK_BLOCK;
            break;
        case BLOCK_GRASS_PLACE:
        case BLOCK_ANVIL_PLACE:
        case BLOCK_CLOTH_PLACE:
        case BLOCK_GLASS_PLACE:
        case BLOCK_GRAVEL_PLACE:
        case BLOCK_LADDER_PLACE:
        case BLOCK_METAL_PLACE:
        case BLOCK_SAND_PLACE:
        case BLOCK_SLIME_PLACE:
        case BLOCK_SNOW_PLACE:
        case BLOCK_STONE_PLACE:
        case BLOCK_WATERLILY_PLACE:
        case BLOCK_WOOD_PLACE:
            pk.sound = LevelSoundEventPacket.Sound.PLACE;
            break;
        case BLOCK_LAVA_POP:
            pk.sound = LevelSoundEventPacket.Sound.POP;
            break;
        case BLOCK_PORTAL_TRAVEL:
            pk.sound = LevelSoundEventPacket.Sound.PORTAL;
            break;
        case BLOCK_LEVER_CLICK:
        case BLOCK_COMPARATOR_CLICK:
        case BLOCK_STONE_BUTTON_CLICK_ON:
        case BLOCK_METAL_PRESSUREPLATE_CLICK_ON:
        case BLOCK_STONE_PRESSUREPLATE_CLICK_ON:
        case BLOCK_TRIPWIRE_CLICK_ON:
        case BLOCK_WOOD_BUTTON_CLICK_ON:
        case BLOCK_WOOD_PRESSUREPLATE_CLICK_ON:
            pk.sound = LevelSoundEventPacket.Sound.POWER_ON;
            break;
        case BLOCK_METAL_PRESSUREPLATE_CLICK_OFF:
        case BLOCK_STONE_BUTTON_CLICK_OFF:
        case BLOCK_STONE_PRESSUREPLATE_CLICK_OFF:
        case BLOCK_TRIPWIRE_CLICK_OFF:
        case BLOCK_WOOD_BUTTON_CLICK_OFF:
        case BLOCK_WOOD_PRESSUREPLATE_CLICK_OFF:
            pk.sound = LevelSoundEventPacket.Sound.POWER_OFF;
            break;
        case BLOCK_NOTE_BASEDRUM:
        case BLOCK_NOTE_BASS:
        case BLOCK_NOTE_BELL:
        case BLOCK_NOTE_CHIME:
        case BLOCK_NOTE_FLUTE:
        case BLOCK_NOTE_GUITAR:
        case BLOCK_NOTE_HARP:
        case BLOCK_NOTE_HAT:
        case BLOCK_NOTE_PLING:
        case BLOCK_NOTE_SNARE:
        case BLOCK_NOTE_XYLOPHONE:
            pk.sound = LevelSoundEventPacket.Sound.NOTE;
            break;
        case BLOCK_PISTON_EXTEND:
            pk.sound = LevelSoundEventPacket.Sound.PISTON_OUT;
            break;
        case BLOCK_PISTON_CONTRACT:
            pk.sound = LevelSoundEventPacket.Sound.PISTON_IN;
            break;
        case ENTITY_BOBBER_THROW:
        case ENTITY_EGG_THROW:
        case ENTITY_ENDERPEARL_THROW:
        case ENTITY_EXPERIENCE_BOTTLE_THROW:
        case ENTITY_LINGERINGPOTION_THROW:
        case ENTITY_SNOWBALL_THROW:
        case ENTITY_SPLASH_POTION_THROW:
        case ENTITY_WITCH_THROW:
            pk.sound = LevelSoundEventPacket.Sound.THROW;
            break;
        case ITEM_FLINTANDSTEEL_USE:
            pk.sound = LevelSoundEventPacket.Sound.IGNITE;
            break;
        case ENTITY_TNT_PRIMED:
            // Fix
            pk.sound = LevelSoundEventPacket.Sound.EVENT_SOUND_TNT;
            break;
        case ENTITY_GENERIC_EXPLODE:
            pk.sound = LevelSoundEventPacket.Sound.EXPLODE;
            break;
        default:
            return null;
    }
    return new PEPacket[] { pk };
}
Also used : Vector3F(org.dragonet.common.maths.Vector3F) PEPacket(org.dragonet.protocol.PEPacket) LevelSoundEventPacket(org.dragonet.protocol.packets.LevelSoundEventPacket)

Example 10 with Vector3F

use of org.dragonet.common.maths.Vector3F in project DragonProxy by DragonetMC.

the class PCEntityHeadLookPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityHeadLookPacket 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.headYaw = packet.getHeadYaw();
    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 = true;
    return new PEPacket[] { pk };
}
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)

Aggregations

Vector3F (org.dragonet.common.maths.Vector3F)13 CachedEntity (org.dragonet.proxy.network.cache.CachedEntity)9 PEPacket (org.dragonet.protocol.PEPacket)8 BlockPosition (org.dragonet.common.maths.BlockPosition)5 MoveEntityPacket (org.dragonet.protocol.packets.MoveEntityPacket)5 PlayerListEntry (com.github.steveice10.mc.protocol.data.game.PlayerListEntry)2 ChunkData (org.dragonet.protocol.type.chunk.ChunkData)2 Section (org.dragonet.protocol.type.chunk.Section)2 RequestException (com.github.steveice10.mc.auth.exception.request.RequestException)1 AuthenticationService (com.github.steveice10.mc.auth.service.AuthenticationService)1 MinecraftProtocol (com.github.steveice10.mc.protocol.MinecraftProtocol)1 ExplodedBlockRecord (com.github.steveice10.mc.protocol.data.game.world.block.ExplodedBlockRecord)1 ClientPluginMessagePacket (com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket)1 ClientSettingsPacket (com.github.steveice10.mc.protocol.packet.ingame.client.ClientSettingsPacket)1 ClientTeleportConfirmPacket (com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket)1 ServerJoinGamePacket (com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket)1 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ByteArrayMeta (org.dragonet.common.data.entity.meta.type.ByteArrayMeta)1