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);
}
Aggregations