Search in sources :

Example 36 with Type

use of com.viaversion.viaversion.api.type.Type in project ViaVersion by ViaVersion.

the class PacketWrapperImpl method set.

@Override
public <T> void set(Type<T> type, int index, T value) throws Exception {
    int currentIndex = 0;
    for (Pair<Type, Object> packetValue : packetValues) {
        if (packetValue.key() != type)
            continue;
        if (currentIndex == index) {
            packetValue.setValue(attemptTransform(type, value));
            return;
        }
        currentIndex++;
    }
    Exception e = new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index);
    throw new InformativeException(e).set("Type", type.getTypeName()).set("Index", index).set("Packet ID", getId()).set("Packet Type", packetType);
}
Also used : PacketType(com.viaversion.viaversion.api.protocol.packet.PacketType) Type(com.viaversion.viaversion.api.type.Type) InformativeException(com.viaversion.viaversion.exception.InformativeException) IOException(java.io.IOException) InformativeException(com.viaversion.viaversion.exception.InformativeException) NoSuchElementException(java.util.NoSuchElementException) CancelException(com.viaversion.viaversion.exception.CancelException)

Aggregations

Type (com.viaversion.viaversion.api.type.Type)36 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)33 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)28 PacketHandler (com.viaversion.viaversion.api.protocol.remapper.PacketHandler)23 Via (com.viaversion.viaversion.api.Via)14 Item (com.viaversion.viaversion.api.minecraft.item.Item)14 ClientWorld (com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld)13 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)11 ClientboundPackets1_13 (com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13)11 Metadata (com.viaversion.viaversion.api.minecraft.metadata.Metadata)10 EntityType (com.viaversion.viaversion.api.minecraft.entities.EntityType)9 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)8 ViaBackwards (com.viaversion.viabackwards.ViaBackwards)8 Position (com.viaversion.viaversion.api.minecraft.Position)8 Chunk (com.viaversion.viaversion.api.minecraft.chunks.Chunk)8 ClientboundPackets1_14 (com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14)8 List (java.util.List)8 ChunkSection (com.viaversion.viaversion.api.minecraft.chunks.ChunkSection)7 ClientboundPackets1_15 (com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15)7 ArrayList (java.util.ArrayList)7