Search in sources :

Example 6 with PEPacket

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

the class StateChangeMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(StateChangeMessage packet) {
    if (packet.reason == StateChangeMessage.Reason.GAMEMODE.ordinal()) {
        if (this.getSession().getPlayer() == null) {
            return null;
        }
        StartGamePacket pkStartGame = new StartGamePacket();
        pkStartGame.eid = this.getSession().getPlayer().getEntityId();
        pkStartGame.gamemode = ((int) packet.value) & 0x1;
        pkStartGame.seed = 0;
        pkStartGame.generator = 1;
        pkStartGame.spawnX = this.getSession().getPlayer().getWorld().getSpawnLocation().getBlockX();
        pkStartGame.spawnY = this.getSession().getPlayer().getWorld().getSpawnLocation().getBlockY();
        pkStartGame.spawnZ = this.getSession().getPlayer().getWorld().getSpawnLocation().getBlockZ();
        pkStartGame.x = (float) this.getSession().getPlayer().getLocation().getX();
        pkStartGame.y = (float) this.getSession().getPlayer().getLocation().getY();
        pkStartGame.z = (float) this.getSession().getPlayer().getLocation().getZ();
        return new PEPacket[] { pkStartGame };
    }
    return null;
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket) StartGamePacket(org.dragonet.net.packet.minecraft.StartGamePacket)

Example 7 with PEPacket

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

the class CloseWindowMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(CloseWindowMessage packet) {
    if (packet.id != 0) {
        this.getTranslator().cachedWindowType[packet.id & 0xFF] = -1;
    }
    WindowClosePacket pkCloseWindow = new WindowClosePacket();
    pkCloseWindow.windowID = (byte) (packet.id & 0xFF);
    getSession().getOpenedWindows().remove(packet.id);
    return new PEPacket[] { pkCloseWindow };
}
Also used : WindowClosePacket(org.dragonet.net.packet.minecraft.WindowClosePacket) PEPacket(org.dragonet.net.packet.minecraft.PEPacket)

Example 8 with PEPacket

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

the class CollectItemMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(CollectItemMessage packet) {
    PickUpItemPacket pkPickUp = new PickUpItemPacket();
    pkPickUp.target = packet.collector;
    pkPickUp.eid = packet.id;
    return new PEPacket[] { pkPickUp };
}
Also used : PickUpItemPacket(org.dragonet.net.packet.minecraft.PickUpItemPacket) PEPacket(org.dragonet.net.packet.minecraft.PEPacket)

Example 9 with PEPacket

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

the class DestroyEntitiesMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(DestroyEntitiesMessage packet) {
    //Remove from the list
    this.getTranslator().cachedEntityIDs.removeAll(packet.ids);
    int[] ids = ArrayUtils.toPrimitive(packet.ids.toArray(new Integer[0]));
    ArrayList<PEPacket> pkRemoveEntity = new ArrayList<>();
    for (int i = 0; i < ids.length; i++) {
        if (!this.getTranslator().cachedPlayerEntities.contains(ids[i])) {
            PEPacket tmp = new RemoveEntityPacket();
            ((RemoveEntityPacket) tmp).eid = ids[i];
            pkRemoveEntity.add(tmp);
        } else {
            GlowPlayer glow = ((GlowPlayer) this.getSession().getPlayer().getWorld().getEntityManager().getEntity(ids[i]));
            PEPacket tmp = new RemovePlayerPacket();
            ((RemovePlayerPacket) tmp).uuid = glow.getUniqueId();
            ((RemovePlayerPacket) tmp).eid = ids[i];
            this.getTranslator().cachedPlayerEntities.remove(new Integer(ids[i]));
            PlayerListPacket pl = new PlayerListPacket(new PlayerListPacket.PlayerInfo(glow.getUniqueId(), -1, null, true, true, null));
            pl.isAdding = false;
            pkRemoveEntity.add(tmp);
            pkRemoveEntity.add(pl);
        }
    }
    return pkRemoveEntity.toArray(new PEPacket[0]);
}
Also used : RemoveEntityPacket(org.dragonet.net.packet.minecraft.RemoveEntityPacket) GlowPlayer(net.glowstone.entity.GlowPlayer) RemovePlayerPacket(org.dragonet.net.packet.minecraft.RemovePlayerPacket) ArrayList(java.util.ArrayList) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) PlayerListPacket(org.dragonet.net.packet.minecraft.PlayerListPacket)

Example 10 with PEPacket

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

the class EntityEffectMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(EntityEffectMessage packet) {
    MobEffectPacket pk = new MobEffectPacket();
    pk.eid = packet.id;
    pk.action = MobEffectPacket.EffectAction.ADD;
    PocketPotionEffect effect = PocketPotionEffect.getByID(packet.effect);
    effect.setAmpilifier(packet.amplifier);
    effect.setParticles(!packet.hideParticles);
    effect.setDuration(packet.duration);
    pk.effect = effect;
    return new PEPacket[] { pk };
}
Also used : PocketPotionEffect(org.dragonet.PocketPotionEffect) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) MobEffectPacket(org.dragonet.net.packet.minecraft.MobEffectPacket)

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