Search in sources :

Example 1 with BlockItemPackets1_15

use of com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15 in project ViaBackwards by ViaVersion.

the class Protocol1_14_4To1_15 method registerPackets.

@Override
protected void registerPackets() {
    executeAsyncAfterLoaded(Protocol1_15To1_14_4.class, MAPPINGS::load);
    translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR);
    translatableRewriter.registerChatMessage(ClientboundPackets1_15.CHAT_MESSAGE);
    translatableRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT);
    translatableRewriter.registerDisconnect(ClientboundPackets1_15.DISCONNECT);
    translatableRewriter.registerOpenWindow(ClientboundPackets1_15.OPEN_WINDOW);
    translatableRewriter.registerTabList(ClientboundPackets1_15.TAB_LIST);
    translatableRewriter.registerTitle(ClientboundPackets1_15.TITLE);
    translatableRewriter.registerPing();
    (blockItemPackets = new BlockItemPackets1_15(this)).register();
    entityRewriter.register();
    SoundRewriter soundRewriter = new SoundRewriter(this);
    soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
    soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
    soundRewriter.registerNamedSound(ClientboundPackets1_15.NAMED_SOUND);
    soundRewriter.registerStopSound(ClientboundPackets1_15.STOP_SOUND);
    // Explosion - manually send an explosion sound
    registerClientbound(ClientboundPackets1_15.EXPLOSION, new PacketRemapper() {

        @Override
        public void registerMap() {
            // x
            map(Type.FLOAT);
            // y
            map(Type.FLOAT);
            // z
            map(Type.FLOAT);
            handler(wrapper -> {
                PacketWrapper soundPacket = wrapper.create(ClientboundPackets1_14.SOUND);
                // entity.generic.explode
                soundPacket.write(Type.VAR_INT, 243);
                // blocks category
                soundPacket.write(Type.VAR_INT, 4);
                // x
                soundPacket.write(Type.INT, toEffectCoordinate(wrapper.get(Type.FLOAT, 0)));
                // y
                soundPacket.write(Type.INT, toEffectCoordinate(wrapper.get(Type.FLOAT, 1)));
                // z
                soundPacket.write(Type.INT, toEffectCoordinate(wrapper.get(Type.FLOAT, 2)));
                // volume
                soundPacket.write(Type.FLOAT, 4F);
                // pitch - usually semi randomized by the server, but we don't really have to care about that
                soundPacket.write(Type.FLOAT, 1F);
                soundPacket.send(Protocol1_14_4To1_15.class);
            });
        }

        private int toEffectCoordinate(float coordinate) {
            return (int) (coordinate * 8);
        }
    });
    new TagRewriter(this).register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY);
    new StatisticsRewriter(this).register(ClientboundPackets1_15.STATISTICS);
}
Also used : BlockItemPackets1_15(com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15) TranslatableRewriter(com.viaversion.viabackwards.api.rewriters.TranslatableRewriter) Entity1_15Types(com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) ServerboundPackets1_14(com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14) BackwardsProtocol(com.viaversion.viabackwards.api.BackwardsProtocol) RegistryType(com.viaversion.viaversion.api.minecraft.RegistryType) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Type(com.viaversion.viaversion.api.type.Type) ImmediateRespawn(com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn) TagRewriter(com.viaversion.viaversion.rewriter.TagRewriter) StatisticsRewriter(com.viaversion.viaversion.rewriter.StatisticsRewriter) BlockItemPackets1_15(com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15) BackwardsMappings(com.viaversion.viabackwards.api.data.BackwardsMappings) Protocol1_15To1_14_4(com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4) EntityTrackerBase(com.viaversion.viaversion.data.entity.EntityTrackerBase) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) ClientboundPackets1_15(com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15) ClientboundPackets1_14(com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14) EntityRewriter(com.viaversion.viaversion.api.rewriter.EntityRewriter) EntityPackets1_15(com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15) SoundRewriter(com.viaversion.viabackwards.api.rewriters.SoundRewriter) StatisticsRewriter(com.viaversion.viaversion.rewriter.StatisticsRewriter) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) TagRewriter(com.viaversion.viaversion.rewriter.TagRewriter) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) SoundRewriter(com.viaversion.viabackwards.api.rewriters.SoundRewriter)

Aggregations

BackwardsProtocol (com.viaversion.viabackwards.api.BackwardsProtocol)1 BackwardsMappings (com.viaversion.viabackwards.api.data.BackwardsMappings)1 SoundRewriter (com.viaversion.viabackwards.api.rewriters.SoundRewriter)1 TranslatableRewriter (com.viaversion.viabackwards.api.rewriters.TranslatableRewriter)1 ImmediateRespawn (com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn)1 BlockItemPackets1_15 (com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15)1 EntityPackets1_15 (com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15)1 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)1 RegistryType (com.viaversion.viaversion.api.minecraft.RegistryType)1 Entity1_15Types (com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types)1 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)1 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)1 EntityRewriter (com.viaversion.viaversion.api.rewriter.EntityRewriter)1 Type (com.viaversion.viaversion.api.type.Type)1 EntityTrackerBase (com.viaversion.viaversion.data.entity.EntityTrackerBase)1 ClientboundPackets1_14 (com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14)1 ServerboundPackets1_14 (com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14)1 ClientboundPackets1_15 (com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15)1 Protocol1_15To1_14_4 (com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4)1 StatisticsRewriter (com.viaversion.viaversion.rewriter.StatisticsRewriter)1